Shift a vector by specified positive or negative lag
shift(x, lag = 1, pad = NA)
x | A vector |
---|---|
lag | Number of lagged offsets, default is 1 |
pad | Value to fill the lagged offset with, default is NA |
a vector, length equal to x, with offset length filled with pad values
Jeffrey S. Evans <jeffrey_evans@tnc.org>
x <- 1:10 shift(x, 1) # shift positive (from beginning of vector) by 1#> Error in UseMethod("shift"): no applicable method for 'shift' applied to an object of class "c('integer', 'numeric')"shift(x, -1) # shift negative (from end of vector) by 1#> Error in UseMethod("shift"): no applicable method for 'shift' applied to an object of class "c('integer', 'numeric')"shift(x, 5, 0) # Shift by 5 and fill (pad) with 0#> Error in UseMethod("shift"): no applicable method for 'shift' applied to an object of class "c('integer', 'numeric')"