[R] Unable to understand strptime() behaviour

Andrew Robinson andrewr at uidaho.edu
Wed Dec 1 10:53:06 CET 2004


Tim,

which aspect of the results?  November has 30 days :)  What is your goal?

(I'm guessing) try:

x <- as.POSIXct(strptime("2002-11-31", format="%Y-%m-%d"))

see e.g.

https://stat.ethz.ch/pipermail/r-help/2003-May/032823.html

I hope that this helps,

Andrew.

On Wed, Dec 01, 2004 at 09:36:37AM +1100, 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
> 
> Tim C
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html

-- 
Andrew Robinson                      Ph: 208 885 7115
Department of Forest Resources       Fa: 208 885 6226
University of Idaho                  E : andrewr at uidaho.edu
PO Box 441133                        W : http://www.uidaho.edu/~andrewr
Moscow ID 83843                      Or: http://www.biometrics.uidaho.edu
No statement above necessarily represents my employer's opinion.




More information about the R-help mailing list