[R] years from as.POSIXlt

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Mar 9 08:40:33 CET 2004


On Mon, 8 Mar 2004, Christian Schulz wrote:

> how it's possible to extract the year and  the number
> of days from Julian date. i'm little confused about the last two
> functions and ?years .
> 
> EDATE  comes from sqlQuery with as.is=T
> EDATE <- as.POSIXlt(datvears$ENROLLDAY)
> > EDATE[1:5] 
> [1] "2000-06-30 11:25:01" "2000-06-30 11:39:55" "2000-06-30 12:11:11"
> [4] "2000-06-30 12:13:32" "2000-06-30 12:50:12"
> > weekdays(EDATE[1:5])
> [1] "Freitag" "Freitag" "Freitag" "Freitag" "Freitag"
> > months(EDATE[1:5])
> [1] "Juni" "Juni" "Juni" "Juni" "Juni"
> > years(EDATE[1:5])
> NULL
> > days(EDATE[1:5])
> NULL

years() and days() are not part of base R: from chron, perhaps?

See ?julian, which says 

Note:

     Other components such as the day of the month or the year are very
     easy to computes: just use 'as.POSIXlt' and extract the relevant
     component.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list