powered by
Shifts a vector's elements left or right by N elements.
shift(x, ...) # S3 method for default shift (x, n = 1, wrap = TRUE, pad = FALSE, ...) # S3 method for data.frame shift (x, ...)
# S3 method for default shift (x, n = 1, wrap = TRUE, pad = FALSE, ...)
# S3 method for data.frame shift (x, ...)
A vector to be operated on
Number of rows to shift by (if negative, shift to right instead of left)
Whether to wrap elements or not (adds the entry at the beginning to the end)
Whether to pad with NAs or not. pad does nothing unless wrap is false, in which case it specifies whether to pad with NAs
Other items to pass along
vector of the same type as vec
# NOT RUN { test <- seq(10) shift(test) # }
Run the code above in your browser using DataLab