Learn R Programming

linea (version 0.1.1)

ma: MA

Description

Moving Average

Usage

ma(v, width, align = "center", zero = TRUE)

Value

The modified vector v

Arguments

v

Numeric vector

width

Width of moving average window as an integer, v

align

Either string "center", "left", or "right"

zero

Boolean to determine the NAs generated by the moving average should be filled with zeros or with the vector's mean.

Details

Applies a moving average on the input vector. The type of moving average is defined by the argument align.

Examples

Run this code
ma(c(1,0,0,0,1,0,0,0,2), 3)
ma(c(1,0,0,0,1,0,0,0,2), 3, align = "right")
ma(c(1,0,0,0,1,0,0,0,2), 3, zero = FALSE)

Run the code above in your browser using DataLab