stats-lag: Lag a 'timeSeries' object

lagR Documentation

Lag a 'timeSeries' object

Description

Compute a lagged version of a "timeSeries" object.

Usage

## S3 method for class 'timeSeries'
lag(x, k = 1, trim = FALSE, units = NULL, ...)

Arguments

x

an object of class timeSeries.

k

an integer number, the number of lags (in units of observations). By default 1. Can also be a vector, in which case the result is a multivariate "timeSeries" in which column i contains the series lagged by k[i], see the examples.

trim

a logical value. By default TRUE, the first missing observation in the return series will be removed.

units

an optional character string, which allows to overwrite the current column names of a "timeSeries" object. By default NULL which means that the column names are selected automatically.

...

arguments passed to other methods.

Value

an object of class "timeSeries"

See Also

lag for ⁠stats::lag⁠, diff

Examples

## Load Micsrosoft Data Set
x <- MSFT[1:20, "Open"]
   
## Lag the 'timeSeries' Object
lag(x, k = -1:1)

timeSeries documentation built on Jan. 13, 2024, 8:16 p.m.