[R] Fwd: as.Date gives NAs when transforming from factor

Omar André Gonzáles Díaz oma.gonzales at gmail.com
Wed Apr 6 01:53:56 CEST 2016


Hi,

I would appreciate your help.

I’m having problems when transforming  a column from “factor” to “date”.



It does not convert just: 31/03/2016 correctly, it out puts: NA.



04/04/2016  turns out as: 2016-04-04



02/04/2016 turns out as: 2016-02-04



31/03/2016 turns out as: NA

03/04/2016 turns out as: 2016-03-04.







Code:

a <- read.csv("dates.csv", stringsAsFactors = F)



a$Date <- as.Date(a$Date, format = "%m/%d/%Y")




Posible Solutions:



I’ve read here that it has to do with the Sys Locale, and the solution was
using: “LC_TIME”, “C”. But I didn’t have success.

http://stackoverflow.com/questions/15566875/as-date-returning-na-in-r






# Sys.getlocale("LC_TIME")

#

# Sys.setlocale("LC_TIME", "C")












Slds,











------------------------------------------------------------------------
> Disclaimer The information in this email and any attachments may contain
proprietary and privileged information that is intended for the
addressee(s) only. If you are not the intended recipient, you are hereby
notified that any disclosure, copying, distribution, retention or use of
the contents of this information is prohibited. When addressed to our
clients or vendors, any information contained in this e-mail or any
attachments is subject to the terms and conditions in any governing
contract. If you have received this e-mail in error, please immediately
contact the sender and delete the e-mail..


More information about the R-help mailing list