moving: Moving Average

View source: R/moving.R

movingR Documentation

Moving Average

Description

Calculate moving average.

Usage

moving(x, k = 5, ends = NA)

Arguments

x

a numeric vector.

k

how many values are evaluated in moving average.

ends

how the ends should be treated.

Details

Alternative end treatments are:

NA use NA values
FALSE truncate, so output is shorter than x
TRUE evaluate moving average on ends, even if the neighbors are all on one side

Value

Vector of same length as x, containing weighted averages.

Note

If k is an even number, a weighted average is used with half weights on each end.

This function is mainly useful if the ends have flat trends, e.g. a diagonal line will have bent ends...

See Also

runmean.


arnima-github/arni documentation built on Oct. 28, 2023, 6:18 p.m.