[Rd] [R] aggregate.ts

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Wed Jul 25 17:02:13 CEST 2007


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).

More information about the R-devel mailing list