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

View source: R/rutils.R

diffxtsR Documentation

Calculate the time differences of an xts time series.

Description

Calculate the time differences of an xts time series.

Usage

diffxts(xtsv, lagg = 1, ...)

Arguments

xtsv

An xts time series.

lagg

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

...

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

Details

The function diffxts() 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 diffit() has incorporated the functionality of diffxts(), so that diffxts() 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

# Calculate time differences over lag by 10 periods
rutils::diffxts(rutils::etfenv$VTI, lag=10)

algoquant/rutils documentation built on June 10, 2025, 3:55 p.m.