Rolling Mean

Computes the rolling mean over a numeric vector.

Usage

rolling_mean(x, window_size, min_periods = window_size, assume_finite = FALSE)

Parameters

Parameter

Description

x

A numeric vector of type double.

window_size

Positive integer window length.

min_periods

Minimum number of non-NA observations required in a window to return a result. Defaults to window_size.

assume_finite

If TRUE, assumes the input contains no NA values and uses a faster SIMD prefix-sum path. Passing TRUE when NA``s are present produces incorrect results. Defaults to ``FALSE.

Returns

A numeric vector with rolling mean values.

Examples

x <- as.double(c(1, 2, 3, 4))
rolling_mean(x, 3L)