Re: [R] Date parsing question

About this list Date view Thread view Subject view Author view Attachment view

From: Gabor Grothendieck (ggrothendieck@myway.com)
Date: Thu 27 May 2004 - 20:50:05 EST


Message-id: <loom.20040527T124224-184@post.gmane.org>

Ajay Shah <ajayshah <at> mayin.org> writes:

>
> How do I parse a date "yyyymmdd"? I tried asking chron(s, "ymd") but
> that didn't work. Would the date parsing routines of the Date class of
> 1.9 grok this?
>

Others have already mentioned z <- as.Date("20040527",format="%Y%m%d")
and if you want it as a chron date try:

chron(unclass(z))

The percent codes in Date are convenient so that's probably the way
to go but just for fun, to do it in chron without using the Date class
you could convert it to the form 05/27/2004 using sub and then apply
chron:

chron(sub("(....)(..)(..)","\\2/\\3/\\1","20040527"))

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:13 EST