Learn R Programming

spatstat.utils (version 3.2-1)

difflong: Lagged Differences for a Long Vector

Description

Calculate the lagged difference of a long vector.

Usage

difflong(x, drop = TRUE)

Value

A vector of the same type as x.

Arguments

x

Numeric or integer vector.

drop

Logical value. See Details.

Author

Adrian Baddeley Adrian.Baddeley@curtin.edu.au.

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).

See Also

Examples

Run this code
  x <- sample(1:5)
  diff(x)
  difflong(x)

Run the code above in your browser using DataLab