View source: R/moving_average.R
moving_average | R Documentation |
A function that calculates a moving or rolling average of a column or vector. It returns the new column or vector that is averaged.
moving_average(column, averaging_width = 5, sides = 2)
column |
A column or vector to be averaged. |
averaging_width |
the amount of neighbouring values to average. |
sides |
One or two sided rolling average, default is two. |
Returns the new column or vector that is moving averaged to overwrite the old one or add as a new column.
mydata$A <- moving_average(mydata$A, 5, 2)
or
mydata$avrA <- moving_average(mydata$A, 5, 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.