[R] strptime "March 14 2010" and NA?
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Feb 8 18:41:22 CET 2011
On Tue, 8 Feb 2011, Manuel Gimond wrote:
> Converting date strings that range between Mar-14-2010 2:00 and
> Mar-14-2010 2:59 (inclusive) to date objects (POSIX) returns a NA entity:
>
> > strptime("3/14/2010 2:00",format="%m/%d/%Y %H:%M")
> [1] "2010-03-14 02:00:00"
>
> This looks fine, however other functions such as plot see a NA object
> instead:
>
> > is.na(strptime("3/14/2010 2:00",format="%m/%d/%Y %H:%M"))
> [1] TRUE
>
> I've processed an entire range of dates for 2010 and have only come
> across this problem for the aforementioned date ranges. For instance,
> the following dates work fine:
>
> > is.na(strptime("3/14/2010 3:00",format="%m/%d/%Y %H:%M"))
> [1] FALSE
>
> > is.na(strptime("10/14/2010 23:00",format="%m/%d/%Y %H:%M"))
> [1] FALSE
>
> which is what I would expect for ALL dates.
>
> Could this be a bug with POSIX or strptime? I'm running R x64 2.12.0 on Win7
You haven't told us your timezone, but very likely you are in one
where that hour did not actually exist (as DST came into effect).
> [[alternative HTML version deleted]]
And you definitely overlooked the request in the posting guide not to
send HTML.
>
> ______________________________________________
> 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