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

Brahm, David David.Brahm at geodecapital.com
Fri Sep 24 17:08:52 CEST 2004


Paul Schwarz <Paul.Schwarz at gartner.com> wrote:
> Is there an R function for calculating moving averages of time series
objects?

Others have replied, but here's the "simple" answer for a trailing 5-day
moving average, no non-standard packages needed:
R> x <- 1:20
R> filter(x, rep(1/5,5), sides=1)

-- David Brahm (brahm at alum.mit.edu)




More information about the R-help mailing list