moving_average | R Documentation |
Centered moving average to smooth out a time series
moving_average(y, r, plotfig = TRUE)
y |
a vector with time series data |
r |
the number of observations to the left of the center in the average, i.e. the function computes a 2r+1 point average. |
plotfig |
if TRUE then a figure is plotted with data and moving average. |
a vector of the same length as y with moving averages (NA at boundaries)
library(SUdatasets) M = moving_average(globaltemp$temp, 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.