I have a list of tibbles, and a list of columns I wish to convert to date class.
library(tibble)
library(purrr)
library(lubridate)
df1 <- tribble(~date_a, ~value_a,
"2017-1-3", 10,
"2018-2-7", 13,
"2018-5-7", 35)
df2 <- tribble(~date_b, ~value_b,
"2014-1-7", 10,
"2018-4-9", 6,
"2018-5-8", 18)
list_dfs <- list(df1, df2)
list_dates <- c("date_a", "date_b")
Trying to use purrr:map
, dplyr:mutate_at
and lubridate::ymd
to efficiently convert these, but getting the following error message:
list_dfs %>% map(~mutate_at(.x, vars(list_dates), ymd))
Error: Strings must match column names. Unknown columns: date_b
This seems similar, but I can't get mapping over tibbles and columns to work.
Do I need to do something clever with purrr::map2
?