shift {Jmisc}R Documentation

shift a vector by shift_by unit

Description

Repeat a vector by row

Usage

shift(x, shift_by)

Arguments

x

a vector

shift_by

number of shift

Author(s)

TszKin Julian Chan ctszkin@gmail.com

Examples

d<-data.frame(x=1:15)
#generate lead variable
d$df_lead2<-shift(d$x,2)
#generate lag variable
d$df_lag2<-shift(d$x,-2)

[Package Jmisc version 0.3.1.1 Index]