Date conversion for Time series

Hi All,

My data frame has this column Time period whose values are string- ex- "Sep 2017"
I intend to change this to a date format.
Could any one help me with this?
Also i'd want "Sep" to be read as the month "September "as i intend to perform a time series analysis on this.
Please advise
Thank you

You can use the lubridate package to convert a variety of character formats into Dates.

If your data frame encodes dates as Sep 2017 you can use the my() function ("my" stands for "month-year") to convert that into a Date value representing September 1, 2017.

df <- data.frame(date = c("Sep 2017", "Oct 2011", "Jun 1912"))
df$date <- lubridate::my(df$date)

Thank you. It worked

1 Like