Skip to content
Prev 336723 / 398513 Next

How to calculate moving average without using filter()?

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: