[R] as.Date() function

philipsm m@ili@g off cp@@el1@stormweb@@et philipsm m@ili@g off cp@@el1@stormweb@@et
Sun Aug 19 23:20:29 CEST 2018


I am having trouble with what must be a very simple problem. Here is a  
reproducible example:

library(lubridate)
st <- c("1961-01","1961-04","1983-02")
print(st)
#[1] "1961-01" "1961-04" "1983-02"
st1 <- as.Date(st, format=("%Y-%m"))
print(st1)
#[1] NA NA NA

Why the heck am I getting three NAs instead of three Dates?I have  
studied the R documentation for as.Date() and it has not turned on the  
light bulb for me.



More information about the R-help mailing list