runmean: Calculate Smoothed Running Mean

View source: R/variance_functions.R

runmeanR Documentation

Calculate Smoothed Running Mean

Description

errbar is a function that allows the calculation of smoothed running means for a numeric vector. It uses the rollmean function from the package zoo to compute rolling means for the numeric vector and then the smoothEnds function from the package stats to smooth the end points of the resulting vector.

Usage

runmean(x, window, align = "center")

Arguments

x

numeric vector representing a series of observations.

window

integer width of the rolling window.

align

character specifying whether the index of the result should be left- or right-aligned or centered (default) compared to the rolling window of observations.

Value

An object of the same class as x with the rolling mean with smoothed ends.

See Also

rollmean, smoothEnds.

Examples

set.seed(1234)
x <- seq(1, 50, 1)
y <- (2 + 2 * x) * rnorm(50, 1, 0.2)
runmean(x = y, window=3)

ballengerj/FishyR documentation built on June 17, 2022, 10:33 p.m.