[R] Unable to understand strptime() behaviour
Prof Brian Ripley
ripley at stats.ox.ac.uk
Wed Dec 1 10:49:55 CET 2004
The result of strptime is a 9-element list. From the help page
Value:
'strptime' turns character representations into an object of class
'"POSIXlt"'.
See Also:
DateTimeClasses for details of the date-time classes; 'locales' to
query or set a locale.
Try ?DateTimeClasses.
On Wed, 1 Dec 2004, Tim Churches wrote:
> R V2.0.1 on Windows XP.
>
> I have read the help pages on strptime() over and over, but can't
> understand why strptime() is producing the following results.
>
> > v <- format("2002-11-31", format="%Y-%m-%d")
> > v
> [1] "2002-11-31"
> > factor(v, levels=v)
> [1] 2002-11-31
> Levels: 2002-11-31
> > x <- strptime("2002-11-31", format="%Y-%m-%d")
> > x
> [1] "2002-12-01"
> > factor(x, levels=x)
> [1] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
> Levels: 2002-12-01 NA NA NA NA NA NA NA NA
I can't understand why you are trying to turn a classed object into a
factor.
--
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