[R-SIG-Finance] Applying function on rolling window basis ** not rollapply() function in zoo

Gabor Grothendieck ggrothendieck at gmail.com
Tue Jan 4 15:20:42 CET 2011


On Tue, Jan 4, 2011 at 8:20 AM, Bogaso Christofer
<bogaso.christofer at gmail.com> wrote:
> Hi all, in the zoo package there is a function rollapply() to apply some
> fixed function on rolling window basis. I am looking for some same sort of
> function on **temporal sampling basis** means, I would like to apply a
> function say mean() for data window of length 30 like observations for 1:30,
> 31:60, . so on.
>
>
>
> Is there any facility to doing that directly?
>

The by= argument of rollapply does that:

> library(zoo)
> z <- zoo(1:9)
> rollapply(z, 3, by = 3, mean)
2 5 8
2 5 8

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-SIG-Finance mailing list