diff_xts: Calculate the time differences of an _xts_ time series.

Description Usage Arguments Details Value Examples

View source: R/rutils.R

Description

Calculate the time differences of an xts time series.

Usage

1
diff_xts(x_ts, lagg = 1, ...)

Arguments

x_ts

An xts time series.

lagg

An integer equal to the number of time periods of lag (default is 1).

...

Additional arguments to function xts::diff.xts().

Details

The function diff_xts() calculates the time differences of an xts time series and pads with zeros instead of NAs. Positive lagg means differences are calculated with values from lagg periods in the past (vice versa for a negative lagg). The function diff() is just a wrapper for diff.xts() from package xts, but it pads with zeros instead of NAs.

The function diff_it() has incorporated the functionality of diff_xts(), so that diff_xts() will be retired in future package versions.

Value

An xts time series with the same dimensions and the same time index as the input series.

Examples

1
2
# Calculate time differences over lag by 10 periods
rutils::diff_xts(rutils::etf_env$VTI, lag=10)

algoquant/rutils documentation built on Feb. 26, 2021, 1:30 a.m.