[R] chron problem: extracting days and years

John Field johnfield at ozemail.com.au
Sat Feb 2 16:50:57 CET 2002


Hello r-help,

I'm trying to split a character vector of dates of the form "dd-mmm-yy" 
into component days, months and years. But

 > library(chron)
 > testdate<-as.POSIXlt(strptime("17-Sep-98","%d-%b-%y"))
 > testdate
[1] "1998-09-17"
 > months(testdate)
[1] "September"    # which is fine, but for days and years I get
 > days(testdate)
NULL
 > years(testdate)
NULL
 >

According to "?days" these should work.  What am I doing wrong?  Is there 
an easier way to achieve what I want?
(I'm running R1.3.0 under Win98).

Many thanks,
John Field

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list