lag_lead: Fast lead/lag for vectors

lead_dtR Documentation

Fast lead/lag for vectors

Description

Find the "next" or "previous" values in a vector. It has wrapped data.table's shift function.

Usage

lead_dt(x, n = 1L, fill = NA)

lag_dt(x, n = 1L, fill = NA)

Arguments

x

A vector

n

a positive integer of length 1, giving the number of positions to lead or lag by. Default uses 1

fill

Value to use for padding when the window goes beyond the input length. Default uses NA

Value

A vector

See Also

lead,shift

Examples

lead_dt(1:5)
lag_dt(1:5)
lead_dt(1:5,2)
lead_dt(1:5,n = 2,fill = 0)

tidyfst documentation built on July 26, 2023, 5:20 p.m.