lead function to shift by one (or more).
Details
Lead and lag are useful for comparing values offset by a constant (e.g. the previous or next value)
Taken from: http://ctszkin.com/2012/03/11/generating-a-laglead-variables/
This function allows me to remove the dplyr::lead depends. Still suggest for vignettes though.
Examples
d <- data.frame(x = 1:15)
# generate lead variable
d$df_lead2 <- ggRandomForests:::shift(d$x, 2)
# generate lag variable
d$df_lag2 <- ggRandomForests:::shift(d$x, -2)
#
#