powered by
lead function to shift by one (or more).
shift(x, shift_by = 1)
a vector of values
an integer of length 1, giving the number of positions to lead (positive) or lag (negative) by
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.
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)
Run the code above in your browser using DataLab