moving_function: Apply function to (centered) moving window

View source: R/sequence_characteristics.R

moving_functionR Documentation

Apply function to (centered) moving window

Description

Apply function to (centered) moving window

Usage

moving_function(x, k = 3, win_fun = sum, na.rm = FALSE, circular = FALSE)

Arguments

x

A numeric vector.

k

An integer value. The width of the moving window.

win_fun

A function. The function must return an object of length one and accept na.rm as argument.

na.rm

A logical value. Used as argument to win_fun.

circular

A logical value. If TRUE, then window wraps around both ends of x, e.g., x represents mean values for day of year.

Value

A numeric vector of the length of x.

References

movingFun

See Also

The package caTools provides fast versions.


DrylandEcology/rSW2utils documentation built on Dec. 9, 2023, 10:44 p.m.