From Achim.Zeileis at wu-wien.ac.at  Wed Jul 25 17:02:13 2007
From: Achim.Zeileis at wu-wien.ac.at (Achim Zeileis)
Date: Wed, 25 Jul 2007 17:02:13 +0200 (CEST)
Subject: [Rd] [R] aggregate.ts
In-Reply-To: <46A75EAA.6020405@bank-banque-canada.ca>
Message-ID: <Pine.LNX.4.44.0707251640420.16266-100000@disco.wu-wien.ac.at>

Paul,

thanks for the feedback. Concerning the zoo side:

> >Currently, the "zoo" implementation allows this: Coercing back and forth
> >gives:
> >  library("zoo")
> >  z1 <- as.ts(aggregate(as.zoo(x1), as.yearqtr, sum))
> >  z2 <- as.ts(aggregate(as.zoo(x2), as.yearqtr, sum))
> >
> >
> This is better, but still potentially misleading. I would prefer a
> default  NA when only some of the observations are available for a
> quarter

In such situations, I either extend the series first to a completely
regular time grid, or modify the function that I use for aggregation to do
exactly what I want it to do.

> (and the syntax is a bit cumbersome for something one needs to
> do fairly often).

I don't think
  aggregate(z, as.yearqtr, sum)
is really cumbersome. And the rest is just coercion back and forth between
"ts" and "zoo"/"zooreg" (which can't be much easier, I guess).
Z



[Rd] [R] aggregate.ts
Achim Zeileis