I have dataframe with a column of dates of the form YYYY/MM, factor class, and I wish to convert it to date class. E.g. 2000/01 -> Jan 2000
I note that as.Date()
is unable to handle date formats without the day component. I have tried using the as.yearmon()
function from the zoo
package.
library('zoo')
as.yearmon(factor("2000-01")) # It works with YYYY-MM format
# [1] "Jan 2000"
as.yearmon(factor("2000/01"))
# [1] NA
as.yearmon(factor("2000/01"),"%y/%m")
# [1] NA
I'm looking for a function that will turn factor("2000/01") to "Jan 2000"
. Any help would be kindly appreciated.