df = data.frame(date = c("Jan-22", "Feb-22", "Mar-23"))
where "Jan-22" means January 2022, etc.
class(df$date) returns that the values are characters rather than dates. I have tried the following to change to Date:
df$date <- as.Date(df$date)
issues
Error in charToDate(x) : character string is not in a standard unambiguous format and
library(dplyr)
df$date <- df$date %>% as.character() % as.Date()
does not work either.
How can I convert this column of characters to Dates?
Try
as.yearmon()function from thezoopackage:Then you can coerce that to Date as such: