[R] Question about Aggregate

Gabor Grothendieck ggrothendieck at gmail.com
Wed Jan 25 13:40:54 CET 2006


Try this:

> library(zoo)
> z <- zooreg(c(12, 13, 12, 14, 16, 15), start = c(2001, 2), freq = 12)
> aggregate(z, trunc(4 * time(z))/4, mean)
2001(1) 2001(2) 2001(3)
   12.5    14.0    15.0


On 1/25/06, Matthieu Cornec <matthieu.cornec at gmail.com> wrote:
> hello,
>
> Suppose you a monthly series you want to aggregate at a quaterly frequency
> with the start and the end of your series in the middle of the quarter.
> For example
>  2001M2 2001M3 2001M4 2001M5 2001M6 2001M7
> 12                  13     12      14         16              15
>
> how can you get something like :
> 2001Q1 2001Q2 200Q3
> NA       14 NA
>
> or
>  2001Q1 2001Q2 200Q3
> 12.5 14 15
>
> Thanks in advance
>
> Matthieu
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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
>




More information about the R-help mailing list