lagk: Create a lagged variable

Description Usage Arguments Value Examples

View source: R/utils.R

Description

Given a variable, create a k lagged version, optionally do it by a grouping factor, such as an ID.

Usage

1
lagk(x, k = 1, by)

Arguments

x

the variable to lag

k

the length to lag it

by

a variable to lag by. Must be sorted.

Value

a vector of the lagged values

Examples

1
lagk(1:4, 1)

JWileymisc documentation built on May 29, 2017, 3:40 p.m.