[R] tidyverse: read_csv() misses column

jim holtman jho|tm@n @end|ng |rom gm@||@com
Tue Nov 2 02:24:33 CET 2021


drop the select, or put tz in the select

Thanks

Jim Holtman
*Data Munger Guru*


*What is the problem that you are trying to solve?Tell me what you want to
do, not how you want to do it.*


On Mon, Nov 1, 2021 at 3:39 PM Rich Shepard <rshepard using appl-ecosys.com>
wrote:

> On Mon, 1 Nov 2021, CALUM POLWART wrote:
>
> > Mutate. Probably.
>
> Calum,
>
> I thought that I had it working, but I'm still missing a piece.
>
> For example,
> > cor_disc %>%
> + select(year, mon, day, hr, min) %>%
> + mutate(
> + sampdt = make_datetime(year, mon, day, hr, min)
> + )
> # A tibble: 415,263 × 6
>      year   mon   day    hr   min sampdt
>     <int> <int> <int> <dbl> <dbl> <dttm>
>   1  2009    10    23     0     0 2009-10-23 00:00:00
>   2  2009    10    23     0    15 2009-10-23 00:15:00
>   3  2009    10    23     0    30 2009-10-23 00:30:00
>   4  2009    10    23     0    45 2009-10-23 00:45:00
>   5  2009    10    23     1     0 2009-10-23 01:00:00
>   6  2009    10    23     1    15 2009-10-23 01:15:00
>   7  2009    10    23     1    30 2009-10-23 01:30:00
>   8  2009    10    23     1    45 2009-10-23 01:45:00
>   9  2009    10    23     2     0 2009-10-23 02:00:00
> 10  2009    10    23     2    15 2009-10-23 02:15:00
> # … with 415,253 more rows
>
> produces the sampdt column, but it, and the timezone, are not present in
> the
> cor_disc tibble:
>
> > cor_disc A tibble: 415,263 × 8
>     site_nbr  year   mon   day    hr   min tz      cfs
>     <chr>    <int> <int> <int> <dbl> <dbl> <chr> <int>
>   1 14171600  2009    10    23     0     0 PDT    8750
>   2 14171600  2009    10    23     0    15 PDT    8750
>   3 14171600  2009    10    23     0    30 PDT    8750
>   4 14171600  2009    10    23     0    45 PDT    8750
>   5 14171600  2009    10    23     1     0 PDT    8750
>   6 14171600  2009    10    23     1    15 PDT    8750
>   7 14171600  2009    10    23     1    30 PDT    8750
>   8 14171600  2009    10    23     1    45 PDT    8730
>   9 14171600  2009    10    23     2     0 PDT    8730
> 10 14171600  2009    10    23     2    15 PDT    8730
> # … with 415,253 more rows
>
> Is the error in the select() or mutate() function specifications?
>
> Thanks,
>
> Rich
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list