[R] strptime "March 14 2010" and NA?
David Winsemius
dwinsemius at comcast.net
Tue Feb 8 17:47:32 CET 2011
On Feb 8, 2011, at 10:31 AM, 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?
More likely it has to do with "daylight savings time".
> I'm running R x64 2.12.0 on Win7
>
>
>
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list