DescTools (version 0.99.8.1)

MoveAvg: Moving Average

Description

Compute a simple moving average (running mean).

Usage

MoveAvg(x, order, align = c("center", "left", "right"))

Arguments

x
univariate time series.
order
order of moving average.
align
specifies whether result should be centered (default), left-aligned or right-aligned.

Value

  • Returns a numeric vector of the same size as x.

Details

The implementation is using the function filter to calculate the moving average.

See Also

There's a faster implementation of running mean in the package caTools runmean() and a slower one in forecast ma().

Examples

Run this code
MoveAvg(AirPassengers, order=5)

Run the code above in your browser using DataLab