Don't give a factor to as.Date. Convert it to character first, or avoid letting it become a factor in the first place by using the stringsAsFactors =FALSE option to the read.table function or its related functions. -- Sent from my phone. Please excuse my brevity.
On April 5, 2016 4:53:56 PM PDT, "Omar André Gonzáles Díaz" <oma.gonza...@gmail.com> wrote: >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.. >______________________________________________ >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.