Reputation: 11
folk!
R can not recognize the next type of date: "Jun 3, 1986"
I tried it several times converting that column to factor or character.
The next examples from stackoverflow do not work and return "NA":
sdate2 <- "jan151999" ndate2 <- as.Date(sdate2, "%B%d%Y"); ndate2
dates <- c("May 27 1984", "July 7 2005") betterDates <- as.Date(dates, format = "%B %d %Y")
I used small letter %b and it did not work also.
Could you help me?
Upvotes: 0
Views: 1209
Reputation: 11
And also this way works well. SOme oone suggested it but deleted afterward.
lubridate::mdy("Jun 3, 1986")
Upvotes: 0
Reputation: 388817
That is probably because your locale language is different. Change it to English and it should work.
Sys.setlocale("LC_ALL","English")
as.Date("Jun 3, 1986", format = "%b %d, %Y")
#[1] "1986-06-03"
Upvotes: 1