movingAverage | R Documentation |
Apply a moving average window as a smoothing function to a numeric vector
movingAverage(x, window = 9, at = names(x), FUN = mean, do.ends = TRUE)
unitIntervalMA(x, step=1)
x |
numeric vector of data to be smoothed by a moving window |
window |
size of the window, in elements of |
at |
numeric vector representing the locations that the values of |
FUN |
averaging function to apply the the windowed subsets of |
do.ends |
logical, should the ends of |
step |
increment stepsize, passed to |
A numeric vector, where the values are the averages in the window, and the names are the locations for the centers of the windows used.
To force the result of movingAverage
to have fixed gaps between
at
, it can be passed to unitIntervalMA
, which uses splines
to interpolate to a new set of locations with a constant step size.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.