difflong: Lagged Differences for a Long Vector

View source: R/longvec.R

difflongR Documentation

Lagged Differences for a Long Vector

Description

Calculate the lagged difference of a long vector.

Usage

difflong(x, drop = TRUE)

Arguments

x

Numeric or integer vector.

drop

Logical value. See Details.

Details

A ‘long vector’ is a vector with more than 2^31 - 1 elements (the largest possible 32-bit integer). Long vectors are supported in R on 64-bit computer systems. This feature was introduced in R version 3.0.0.

Although long vectors are permitted, not all functions in R have been extended to handle long vectors.

The base R function diff currently does not handle a long vector, and may cause the entire R session to be terminated.

The function difflong is a temporary replacement for diff in the simplest case: difflong(x) is a replacement for diff(x).

If drop=TRUE (the default), the result of difflong(x) is equivalent to diff(x), a vector with length equal to length(x) - 1. If drop=FALSE the result of difflong(x, FALSE) has the same length as x; the first entry is zero, and the subsequent entries are equivalent to diff(x).

Value

A vector of the same type as x.

Author(s)

\adrian

.

See Also

diff

Examples

  x <- sample(1:5)
  diff(x)
  difflong(x)

spatstat.utils documentation built on Jan. 10, 2026, 9:12 a.m.