[R] "moving average" method for time series objects

Kjetil Brinchmann Halvorsen kjetil at acelerate.com
Fri Sep 24 14:34:19 CEST 2004


Schwarz,Paul wrote:

>Dear R-Help readers,
>
>I suspect that this question must be a FAQ, but my investigation of the archives has not been very revealing.  Is there an R function for calculating moving averages of time series objects?
>
>  
>
 library(gregmisc)
 ?running
 test <- ts(rnorm(100))

 test2 <- running(test, fun=median, width=10)
 length(test2)
[1] 91

you want fun=mean

Kjetil

-- 

Kjetil Halvorsen.

Peace is the most effective weapon of mass construction.
               --  Mahdi Elmandjra




More information about the R-help mailing list