Reputation: 5
I am trying to convert into date in the R Language then i have getting NA. Tried setting up the LOCALE but still issue. Please advise. Here is the snapshot of what i am trying to do :
## Stored the date into X**
x <- c("2014-12-01", "2014-12-15", "2014-12-20", "2014-12-25")
## Tring to convert the date in the format dd-MMM-YYYY BUT GETTING error**
as.Date(x,"%d-%B-%y")
[1] NA NA NA NA
## Tried setting the LOCALE. See the current locale below**
Sys.getlocale("LC_TIME");
[1] "English_United States.1252"
Upvotes: 0
Views: 155
Reputation:
This should work:
x <- c("2014-12-01", "2014-12-15", "2014-12-20", "2014-12-25")
format(as.Date(x), "%d-%b-%Y")
#[1] "01-Dec-2014" "15-Dec-2014" "20-Dec-2014" "25-Dec-2014"
Upvotes: 6