diff: Lagged Differences for 'tind' and 'tdiff' Objects

diffR Documentation

Lagged Differences for tind and tdiff Objects

Description

diff method for tind and tdiff works in a standard way. For all index types except for integer and numeric indices, differences of time indices are retuned as objects of tdiff class.

Usage

## S3 method for class 'tind'
diff(x, lag = 1L, differences = 1L, ...)

## S3 method for class 'tdiff'
diff(x, lag = 1L, differences = 1L, ...)

Arguments

x

an object of tind class or tdiff class.

lag

an integer value.

differences

an integer value.

...

(ignored) further arguments passed to or from other methods.

Value

An object of tdiff class, except for x argument of tind class of type "i" or "n" (integer/numeric indices), in which case an integer or numeric vector is returned.

See Also

Ops.

Examples

(nn <- sample(1:10))
(x <- today() + nn)
# all 3 should be the same
diff(x, 2, 2)
as.tdiff(diff(nn, 2, 2), "d")
diff(as.tdiff(nn, "d"), 2, 2)


tind documentation built on Dec. 28, 2025, 1:06 a.m.