Re: [R] zoo, zooreg, & ISOdatetime

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Sat 27 Aug 2005 - 12:15:03 EST

On 8/26/05, David James <djames@frontierassoc.com> wrote:
> I create a zooreg object that runs from Jan-1-2002 0:00 to Jun-1-2005
> 0:00...
>
> regts.start = ISOdatetime(2002, 1, 1, hour=0, min=0, sec=0, tz="")
> regts.end = ISOdatetime(2005, 6, 1, hour=0, min=0, sec=0, tz="")
> regts.zoo <- zooreg( NA, regts.start, regts.end, deltat=3600 )
>
> Upon inspection:
> > regts.zoo[1:3]
> 2002-01-01 00:00:00 2002-01-01 01:00:00 2002-01-01 02:00:00
> NA NA NA
>
> > regts.zoo[29926:29928]
> 2005-05-31 22:00:00 2005-05-31 23:00:00 2005-06-01 00:00:00
> NA NA NA
>
> However:
> > summary(regts.zoo)
> Error in "row.names<-.data.frame"(`*tmp*`, value = c("2002-01-01
> 00:00:00", :
> duplicate 'row.names' are not allowed
>
> I don't understand why it claims that there are duplicate row.names.

Because you are using tz = "" and when the time falls back in fall 2am is 1am so you wind up having two 1am's which is not allowed. The times themselves are
ok but the names are duplicated which is not allowed either. Thanks for finding this problem.

> Any advice?

  1. Use tz = "GMT" rather than tz = "" since GMT has no daylight savings time and won't result in duplicate names.

> regts.start = ISOdatetime(2002, 1, 1, hour=0, min=0, sec=0, tz="GMT")
> regts.end = ISOdatetime(2005, 6, 1, hour=0, min=0, sec=0, tz="GMT")
> regts.zoo <- zooreg( NA, regts.start, regts.end, deltat=3600 )

2. As advised last time use chron if you don't need time zones.

3. Read the R News 4/1 article I previously recommended, which has the same advice as #2 plus a lot more info on dates and times.

4. If you are using time zones and do need POSIXct and tz = "" then let me know privately and I will send you the devel version of zoo where I just fixed it.

>
> I probably could use the aggregate function to clean this up, but I
> don't see why it should be needed (provided that I do things properly
> in the first place).

Yes. It should not be needed.

>
> Thanks,
> David
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Aug 27 12:21:14 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 16:00:36 EST