I am trying to use as.POSIXct
in R
to convert a vector of characters with the following format: "YYYY/MM"
Unfortunately, I have discovered a strange error -- the following code returns NA
:
as.POSIXct("2014/12", "%Y/%m")
[1] NA
When I interpret the second number as a day everything works fine:
as.POSIXct("2014/12", "%Y/%d")
[1] "2014-07-12 CDT"
If I add a third number representing a day of month, everything works fine:
as.POSIXct("2014/12/01", "%Y/%m/%d")
[1] "2014-12-01 CDT"
Anybody have any idea why I'm getting an NA
for the first code chunk?