[R] tidyverse: read_csv() misses column

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Tue Nov 2 08:39:50 CET 2021

On Mon, 1 Nov 2021 15:24:47 -0700 (PDT)
Rich Shepard <rshepard using appl-ecosys.com> wrote:

> + mutate(
> + sampdt = make_datetime(year, mon, day, hr, min)
> + )


> produces the sampdt column, but it, and the timezone, are not present
> in the cor_disc tibble

That's because mutate() doesn't, well, mutate its argument. It _returns_
its changes, but it doesn't save them in the original variable. It's
your responsibility to assign the result somewhere:

cor_disc |> select(...) |> mutate(...) -> cor_disc_mutated

(Idiomatic R makes it hard to accidentally change the value of the
variable passed to a function from inside of that function. Anything
short of environments, reference class objects and/or non-standard
evaluation will not affect the value outside the function call.)

Best regards,

More information about the R-help mailing list