false NA value in time series dataset

I have a time series dataset that looks like df below.
I got as NA in place of 1970-04-2602:00:00 0.142 even though all dataset looks like the same.
could anyone share why is it so?
How could I solve it?

df=read.table(header = TRUE,text = "
datetime            value
1970-01-0100:00:00	0
1970-01-0100:00:00	0
1970-04-2600:00:00	0.043
1970-04-2601:00:00	0.041
1970-04-2602:00:00	0.142
1970-04-2603:00:00	0.116
1970-04-2604:00:00	0.072")
df$time=format(round(df$time, units="hours"), format="%Y-%m-%d %H:%M:%S")


Look at this (on a Windows, New York-time, computer):

> as.POSIXct("1970-04-26 01:59:59",format="%Y-%m-%d %H:%M:%S")
[1] "1970-04-26 01:59:59 EST"
> as.POSIXct("1970-04-26 01:59:60",format="%Y-%m-%d %H:%M:%S")
[1] "1970-04-26 03:00:00 EDT"

Depending on your locale, it seems on 1970-04-26 there is the switch to Summer time, and there is no 2 am (the entire hour is just skipped). This disappears if you specify a time-zone:

> as.POSIXct("1970-04-26 01:59:59",format="%Y-%m-%d %H:%M:%S", tz="UTC")
[1] "1970-04-26 01:59:59 UTC"
> as.POSIXct("1970-04-26 01:59:60",format="%Y-%m-%d %H:%M:%S", tz="UTC")
[1] "1970-04-26 02:00:00 UTC"
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.