diff1_i: 1-Unit Lagged Differences for Integer Values

Description Usage Arguments Value Examples

View source: R/RcppExports.R

Description

Written in C++, this function should always run faster than diff for calculating differences between adjacent values of an integer vector.

Usage

1

Arguments

x

Integer vector.

Value

Integer vector.

Examples

1
2
3
4
# diff1_i is typically much faster than diff
x <- rpois(1000, lambda = 5)
all.equal(diff(x), diff1_i(x))
benchmark(diff(x), diff1_i(x), replications = 2000)

dvmisc documentation built on May 2, 2019, 5:51 p.m.