Question about Aggregate

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about Aggregate

Matthieu Cornec
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]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Question about Aggregate

Gabor Grothendieck
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 <[hidden email]> 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]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Question about Aggregate

Spencer Graves
In reply to this post by Matthieu Cornec
          Did you try 'RSiteSearch("aggregate time series")'?  When I did this
just now, the third hit was,
"http://finzi.psych.upenn.edu/R/Rhelp02a/archive/55761.html", which
might help you.  See in particular the "zoo" package and vignette, and
especially the "aggregate.zoo" function, including the examples with the
documentation.

          If you'd like to submit another question to this listserver, PLEASE
do read the posting guide! "www.R-project.org/posting-guide.html".
People who follow more closely the procedure outlined there generally
get better answers quicker, I believe.

          hope this helps,
          spencer graves

Matthieu Cornec 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]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html