[R] seq.POSIXt creates duplicate entries

David Winsemius dwinsemius at comcast.net
Thu Dec 10 00:33:22 CET 2015


> On Dec 9, 2015, at 10:58 AM, Micha Silver <micha at arava.co.il> wrote:
> 
> Hello all:
> I am creating a time series using seq.POSIXt.
> 
> ts.full <- as.character(seq.POSIXt(as.POSIXct(start(d.zoo)), as.POSIXct(end(d.zoo)), by="hour"))
> 
> The period crosses the hour of change from "summer time" to "winter time". When checking with:
> duplicated(ts.full)
> I see that there are some duplicate hours. These fall right at the time change. How can I avoid this? (or remove the duplicates)?

If you want us to redefine Daylight Savings time, then you should specify in great detail exactly how this should be done. 

I don’t see any duplicates, anyway, since the DST zones are incuded:

> seq(as.POSIXct("2015-10-31 23:00"), as.POSIXct("2015-11-01 4:00"), by="1 hour")
[1] "2015-10-31 23:00:00 PDT" "2015-11-01 00:00:00 PDT" "2015-11-01 01:00:00 PDT"
[4] "2015-11-01 01:00:00 PST" "2015-11-01 02:00:00 PST" "2015-11-01 03:00:00 PST"
[7] "2015-11-01 04:00:00 PST”

But if you use GMT you do get a sequence with no “duplicates:

> seq(as.POSIXct("2015-10-31 23:00", tz="GMT"), as.POSIXct("2015-11-01 4:00", tz="GMT"), by="1 hour")
[1] "2015-10-31 23:00:00 GMT" "2015-11-01 00:00:00 GMT" "2015-11-01 01:00:00 GMT"
[4] "2015-11-01 02:00:00 GMT" "2015-11-01 03:00:00 GMT" "2015-11-01 04:00:00 GMT"

> 
> Thanks
> -- 
> Micha Silver
> Arava Drainage Authority
> +972-523-665918
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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
Alameda, CA, USA



More information about the R-help mailing list