Learn R Programming

matrixStats (version 0.53.1)

diff2: Fast lagged differences

Description

Computes the lagged and iterated differences.

Usage

diff2(x, idxs = NULL, lag = 1L, differences = 1L, ...)

Arguments

x

A numeric vector of length N.

idxs

A vector indicating subset of elements to operate over. If NULL, no subsetting is done.

lag

An integer specifying the lag.

differences

An integer specifying the order of difference.

...

Not used.

Value

Returns a numeric vector of length N - differences.

See Also

diff().

Examples

Run this code
# NOT RUN {
diff2(1:10)

# }

Run the code above in your browser using DataLab