moving_mean {dvmisc}R Documentation

Moving Averages

Description

Calculates moving averages or maximum moving average. For optimal speed, use integer = TRUE if x is an integer vector and integer = FALSE otherwise.

Usage

moving_mean(x, window, integer = FALSE, max = FALSE)

Arguments

x

Integer or numeric vector.

window

Integer value specifying window length.

integer

Logical value for whether x is an integer vector.

max

Logical value for whether to return maximum moving average (as opposed to vector of moving averages).

Value

Numeric value or vector depending on max.

Examples

# 5-unit moving average for integer vector of length 10
x <- rpois(10, lambda = 3)
moving_mean(x, 5)



[Package dvmisc version 1.1.4 Index]