moving_average: A function that calculates a moving average of a column or...

View source: R/moving_average.R

moving_averageR Documentation

A function that calculates a moving average of a column or vector.

Description

A function that calculates a moving or rolling average of a column or vector. It returns the new column or vector that is averaged.

Usage

moving_average(column, averaging_width = 5, sides = 2)

Arguments

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.

Value

Returns the new column or vector that is moving averaged to overwrite the old one or add as a new column.

Examples

mydata$A <- moving_average(mydata$A, 5, 2)

or
mydata$avrA <- moving_average(mydata$A, 5, 2)


SamLoontjens/HandlingLicorFiles documentation built on Nov. 14, 2023, 6:32 a.m.