Learn R Programming

tind (version 0.2.4)

diff: 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 tind
diff(x, lag = 1L, differences = 1L, ...)

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

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.

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.

See Also

Examples

Run this code
(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)

Run the code above in your browser using DataLab