I\'m looking for a straightforward way to convert all of the variables in a data frame which begin with \'date\' to dates using lubridate::dmy() (they are curre
lubridate::dmy()
You can use mutate_at()
mutate_at()
library(dplyr) library(lubridate) df <- mutate_at(df, vars(starts_with("date")), funs(dmy))
or use mutate_if to mutate all date columns to dmy. Using is.Date from lubridate.
mutate_if
is.Date
lubridate
df <- mutate_if(df, is.Date, funs(dmy))