Similar to the lag function from the stats package, but glag enables padding (e.g. NAs or 0s) of the lost entries. NOTE: contrary to lag the glag function can only be applied to vectors
Usage
glag(x, k = 1, pad = FALSE, pad.value = NA)
Arguments
x
a numeric vector
k
integer equal to the lag (the default is 1)
pad
logical. If TRUE, then the lost entries are padded with pad.value. If FALSE (default), then no padding is undertaken