ma: ma

Description Usage Arguments Details Value Author(s)

View source: R/timeseries.R

Description

ma

Usage

1
ma(x, left_interval = 1, right_interval = 1, na.rm = TRUE)

Arguments

x

A numeric vector

left_interval

an integer value of the number of values to include in the average to the LEFT of a given position

right_interval

an integer value of the number of values to include in the average to the RIGHT of a given position

na.rm

Should be na values be ignored?

Details

The moving average of a set of values. This function calculates the moving average across an interval. The interval is no consistently large as the extreme left and right of the vector since the interval 'walks' off the end of the vector where there are no values. The effect is that if you have a left interval of 2 and right interval of 2. The returns 1st index in the vector is the mean(x[1:3]), the 2nd is mean(x[1:4]), the 3rd is mean(x[1:5]), the 4th is mean(x[2:6]), the 5th is mean(x[3:7]) and so on. At the right end of the vector the same occurs in the opposite direction. The alternative approach is to return NA for return indexes 1:2 because you cannot calculate the moving average with a left interval of 2 for those values; this mthod is not implemented.

Value

A numeric vector

Author(s)

Thomas Rosendal


SVA-SE/svamap documentation built on Sept. 25, 2020, 3:53 p.m.