lagDistance: Distance with lag

Description Usage Arguments Value Author(s)

Description

Calculate the distance between each element in a numeric vector and the element that is lag positions after it. For the last lag elemnts, this distance does not exist, so NA is used as a placeholder. The returned vector is of the same length as the input vector.

Usage

1
lagDistance(vec, lag = 1, reverse = FALSE)

Arguments

vec

numeric.

lag

integer.

reverse

logical. Default to FALSE, i.e. calculate vec[i+lag] - vec[i]. When set to TRUE, calculate vec[i] - vec[i+lag]

Value

numeric.

Author(s)

Kaiyin Zhong, Fan Liu


CollapsABEL documentation built on May 1, 2019, 7:28 p.m.