smooth_ma: Moving-average smoothing

Description Usage Arguments Value Examples

View source: R/09-smooth.R

Description

Experimental lifecycle

Computes a simple moving average smoother.

Usage

1
smooth_ma(x, order = NULL, centre = TRUE, fill = NA)

Arguments

x

[univariate vector]

Univariate vector, numeric or ts object with only one dimension.

order

[integer(1): NULL]

Order of moving average smoother.

centre

[logical(1): TRUE]

Centers the moving average for even orders.

fill

[numeric or function: NA]

Numeric value(s) or function used to fill observations.

Value

Returns a vector with the same class and attributes as the input vector.

Examples

1
2
3
4
5
6
x <- co2
x <- c(1:3, 5, 4, 7:3, 2*(2:5), rep(10, 4))#sin(1:100)
plotx(x)
lines(smooth_ma(x, 4), col = "red")
lines(smooth_spline(x), col = "purple")
lines(smooth_loess(x), col = "green")

kvasilopoulos/transx documentation built on Jan. 26, 2021, 6:14 p.m.