[R] Problems with as.POSIXct
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Sep 22 18:13:00 CEST 2011
What timezone is this?
In America/Bogota there was no midnight that day, so the time would be
invalid. The Olson database has
# Colombia
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule CO 1992 only - May 3 0:00 1:00 S
Rule CO 1993 only - Apr 4 0:00 0
-
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone America/Bogota -4:56:20 - LMT 1884 Mar 13
-4:56:20 - BMT 1914 Nov 23 # Bogota Mean Time
-5:00 CO CO%sT # Colombia Time
When all else fails, read the help:
Character input is first converted to class ‘"POSIXlt"’ by
‘strptime’: numeric input is first converted to ‘"POSIXct"’. Any
conversion that needs to go between the two date-time classes
requires a timezone: conversion from ‘"POSIXlt"’ to ‘"POSIXct"’
will validate times in the selected timezone. One issue is what
happens at transitions to and from DST, for example in the UK
as.POSIXct(strptime('2011-03-27 01:30:00', '%Y-%m-%d %H:%M:%S'))
as.POSIXct(strptime('2010-10-31 01:30:00', '%Y-%m-%d %H:%M:%S'))
are respectively invalid (the clocks went forward at 1:00 GMT to
2:00 BST) and ambiguous (the clocks went back at 2:00 BST to 1:00
GMT).
On Thu, 22 Sep 2011, KENNETH R CABRERA wrote:
> Hi R users:
>
> This is a very strange problem:
>
> Why this instruction shows me NA?,
> and any other date shows me that error!
>
> as.POSIXct(strptime("1992-5-3",format="%Y-%m-%d"))
>
> This is my R version on windows 7.
> "R version 2.13.1 Patched (2011-08-25 r56794)"
>
> Thank you for your help.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
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