For some strange reasons, I'm having problems converting the date 2008-10-26 02:00:00 to POSIXct in R. I have been working on millions of dates and it seems that I always stumble across the same problem with dates ranging from 2008-10-26 02:00:00 to 2008-10-26 02:59:59 (anything with 2008-10-26 2pm).
For example, it works normally with:
> as.POSIXct("2008-10-26 03:00")
[1] "2008-10-26 03:00:00 +05"
But with 2008-10-26 02:00:00:
> as.POSIXct("2008-10-26 02:00")
[1] "2008-10-26 +04"
The dates were originally in a data frame in the format %Y-%m-%dT%H:%M:%SZ
. I used the code measurement_date = as.POSIXct(df_txt$V1, format = "%Y-%m-%dT%H:%M:%SZ")
to convert all the dates to POSIXct, and in the data frame I'm left with NAs, as shown:
> df[80960:80970,]
study_id measurement_date oxy_conc ph salinity temp
80960 87 2008-10-26 01:50:00 NA NA NA 10.38
80961 87 <NA> NA NA NA 10.37
80962 87 <NA> NA NA NA 10.36
80963 87 <NA> NA NA NA 10.36
80964 87 <NA> NA NA NA 10.35
80965 87 <NA> NA NA NA 10.33
80966 87 <NA> NA NA NA 10.33
80967 87 2008-10-26 03:00:00 NA NA NA 10.34
80968 87 2008-10-26 03:10:00 NA NA NA 10.35
80969 87 2008-10-26 03:20:00 NA NA NA 10.34
80970 87 2008-10-26 03:30:00 NA NA NA 10.36
I even tried working around the problem through calculations. For example, in the code below I tried adding 10 minutes to 2008-10-26 01:50, but even here it fails:
> as.POSIXct("2008-10-26 01:50")+60*10
[1] "2008-10-26 03:00:00 +05"
Any help will be greatly appreciated. Thank you very much!