I am trying to parse a date with 2 digit years. However this does not work. Can somebody please tell me why?
Browse[1]> as.Date("Jan-84", format = "%b-%y")
[1] NA
I am trying to parse a date with 2 digit years. However this does not work. Can somebody please tell me why?
Browse[1]> as.Date("Jan-84", format = "%b-%y")
[1] NA
The zoo package is helpful for this:
require(zoo)
x <- as.yearmon("Jan-84", format = "%b-%y")
The lines above first convert the input to class yearmon:
"Jan 1984"
From there you can convert the yearmon class to Date (or POSIXct), like this:
x <– as.Date(x)
Now the object is of class Date:
"1984-01-01"