[R] Date formats

Rui Barradas ruipbarradas at sapo.pt
Wed Jun 20 01:37:52 CEST 2012


Hello,

Try

as.Date("01OCT1928", format="%d%b%Y")
[1] "1928-10-01"


Note that though probably not a problem to you, this is locale specific. 
In Portugal, the string corresponding to the same date would be 
"01OUT1928". The variable to set using Sys.setlocale() would be LC_TIME.

For date formats the help page you want is

help("strptime")
?strptime


Hope this helps,

Rui Barradas

Em 19-06-2012 13:00, Data Analytics Corp. escreveu:
> Hi,
>
> I imported an excel table (using read.csv) of Dow Jones monthly average
> closings where the first variable is a date as a character string such
> as "01OCT1928".  How do I convert this to a date variable so I can plot
> monthly average closings against date using ggplot2?
>
> Thanks,
>
> Walt
>
> ________________________
>
> Walter R. Paczkowski, Ph.D.
> Data Analytics Corp.
> 44 Hamilton Lane
> Plainsboro, NJ 08536
> ________________________
> (V) 609-936-8999
> (F) 609-936-3733
> walt at dataanalyticscorp.com
> www.dataanalyticscorp.com
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.



More information about the R-help mailing list