Skip to content
Prev 383913 / 398502 Next

Date from text

Hi, 

For the usual R text to date conversions, you need a complete date. Since you are missing the day of the month in your source text, you would need to impute that part before making the conversion.

Also, since you don't appear to need to worry about time of day, just use as.Date(), instead of as.POSIXct().

In this case, use ?sub to add the day of the month to the source text, for which I will impute the 15th, and then make the conversion:

## Single value for now
x <- "11-1993"
[1] "11-15-1993"
[1] "1993-11-15"


Regards,

Marc Schwartz