powered by
Smoothing a time series with moving averages using the filter function.
filter
ma(x, n, sides = "past")
a vector as long as x, but smoothed. Possibly with NAs.
numeric vector to be smoothed
numeric vector of length one determining the width of the smoothing window
one of 'past', 'center' or 'future' indicating the side of the filter.)
'past'
'center'
'future'
ma(1:10, n = 3, sides = 2) # centred around lag 0 ma(1:10, n = 3) # past values
Run the code above in your browser using DataLab