Shift a vector left or right by a number of spaces. From: https://stackoverflow.com/a/30542172/1898713 library(SOfun); shifter(a)#'

shifter(x, n = 1)

Arguments

x

a numeric vector

n

an integer, the number of indices to shift the input vector. Positive, shifts left; negative, shifts right.

Value

a numeric vector

Examples

library(ARCOS)
ARCOS:::shifter(1:10, 2)
#>  [1]  3  4  5  6  7  8  9 10  1  2