MoveAvg | R Documentation |
Compute a simple moving average (running mean).
MoveAvg(x, order, align = c("center", "left", "right"),
endrule = c("NA", "keep", "constant"))
x |
univariate time series. |
order |
order of moving average. |
align |
specifies whether result should be centered (default), left-aligned or right-aligned. |
endrule |
character string indicating how the values at the beginning and the end (of the data) should be treated.
|
The implementation is using the function filter
to calculate the moving average.
Returns a vector of the same size and same class as x.
Andri Signorell <andri@signorell.net>
There's a faster implementation of running mean in the package caTools runmean()
and a slower one in forecast ma()
. There's similar code in Midx()
.
MoveAvg(AirPassengers, order=5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.