[R] How to calculate moving average without using filter()?

Rui Barradas
2014-02-17T19:07:52Z

Hello,

Many packages have a movind average function. For instance package
forecast. Or

library(sos)
findFn("moving average")

In your example, what you compute is not exactly a moving average, but
in can be computed with something like the following.

s <- (seq_along(dat) - 1) %/% 3
sapply(split(dat, s), mean)


Hope this helps,

Rui Barradas


Em 17-02-2014 18:45, C W escreveu: