I'm trying to generate a time series from 2000-01-01 00:00:00 to 2020-12-31 23:00:00 (hourly timestep), without taking into account daylight savings. Other posts suggest using GMT or UTC when generating it as POSIX. So this is what I tried:
## create date seq
Dates <- seq(as.POSIXct("2000-01-01 00:00:00"), as.POSIXct("2020-12-31 23:00:00"), by = "hour", tz='UTC')
Dates <- as.data.frame(Dates)
colnames(Dates)[1] <- "DatesR"
## check dup 2
testing <- as.character(Dates$DatesR)
dup <- as.data.frame(which(duplicated(testing))) ## not good
As you can see, duplicates are still present. Skipped values also exist.
I also tried using zone instead of tz, like that:
## create date seq
Dates <- seq(as.POSIXct("2000-01-01 00:00:00"), as.POSIXct("2020-12-31 23:00:00"), by = "hour", zone='UTC')
Dates <- as.data.frame(Dates)
colnames(Dates)[1] <- "DatesR"
## check dup 2
testing <- as.character(Dates$DatesR)
dup <- as.data.frame(which(duplicated(testing))) ## not good
Still doesn't work. Any recommendations??
tz=is an argument ofas.POSIXct, not ofseq.It is also possible to set the entire session to default to UTC.
Also note that
seqdoes not actually produce any duplicates using the default time zone. It is the conversion to character that introduces the duplicates.