| shift {DataCombine} | R Documentation | 
A function for creating lag and lead variables.
Description
The function shifts a vector up or down to create lag or lead variables. Note: your data needs to be sorted by date. The date should be ascending (i.e. increasing as it moves down the rows).
Usage
shift(VarVect, shiftBy, reminder = TRUE)
Arguments
VarVect | 
 a vector you would like to shift (create lag or lead).  | 
shiftBy | 
 numeric value specifying how many rows (time units) to shift the data by. Negative values shift the data down–lag the data. Positive values shift the data up–lead the data.  | 
reminder | 
 logical. Whether or not to remind you to order your data by
the   | 
Details
shift a function for creating lag and lead variables, including for
time-series cross-sectional data.
Value
a vector
Source
Largely based on TszKin Julian's shift function:
http://ctszkin.com/2012/03/11/generating-a-laglead-variables/.