ma: Simple Moving Average

View source: R/misc.R

maR Documentation

Simple Moving Average

Description

Smoothing a time series with moving averages using the filter function.

Usage

ma(x, n, sides = "past")

Arguments

x

numeric vector to be smoothed

n

numeric vector of length one determining the width of the smoothing window

sides

one of 'past', 'center' or 'future' indicating the side of the filter.)

Value

a vector as long as x, but smoothed. Possibly with NAs.

See Also

filter

Examples

ma(1:10, n = 3, sides = 2)    # centred around lag 0
ma(1:10, n = 3)               # past values

lfstat documentation built on Nov. 10, 2022, 5:42 p.m.