I have date in character vector. I need to convert it to date format.
For example :
Month = "202005"
Output should be May-20
. It should be in date format so that I can use to filter some dates. Similarly 201912
should return Dec-19
I have date in character vector. I need to convert it to date format.
For example :
Month = "202005"
Output should be May-20
. It should be in date format so that I can use to filter some dates. Similarly 201912
should return Dec-19
zoo
has a function called yearmon()
.
library(zoo)
month <- "202005"
as.yearmon(month, "%Y%m")
# "May 2020"