Reputation: 1451
As working in a big data table I found NA values in a datetime column where they should not be... All these values should be "2014-03-30 02:00:00".
I made some trials:
> as.POSIXct("2014-03-03 02:00:00")
[1] "2014-03-03 02:00:00 CET"
> as.POSIXct("30/03/2014 2:00", format = "%d/%m/%Y %H:%M")
[1] NA
> as.POSIXct("30/03/2014 0:00", format = "%d/%m/%Y %H:%M")
[1] "2014-03-30 CET"
> as.POSIXct("30/03/2014 4:00", format = "%d/%m/%Y %H:%M")
[1] "2014-03-30 04:00:00 CEST"
Any idea why only
as.POSIXct("30/03/2014 2:00", format = "%d/%m/%Y %H:%M")
produces NA?!!
Upvotes: 4
Views: 102
Reputation: 2989
As I pointed out in my comment, the solution here is to use
as.POSIXct("30/03/2014 2:00", format = "%d/%m/%Y %H:%M", tz = "GMT")
where GMT
can be replaced with your respective time zone.
As you already pointed out, the reason is the change from wintertime to summertime
Any time in between
as.POSIXct("30/03/2014 2:00", format = "%d/%m/%Y %H:%M")
and
as.POSIXct("30/03/2014 2:59", format = "%d/%m/%Y %H:%M")
won't work, since this time did not exist in your country (probably in Europe)
Upvotes: 3