rotate.Rd
rotate a vector by given number of positions forward or backwards
rotate(vec, by = 1L)
vec | A vector |
---|---|
by | An integer indicating number of positions. Default is 1L |
A vector after rotating it
rotate(1:10, 2)#> [1] 3 4 5 6 7 8 9 10 1 2rotate(letters, -5)#> [1] "v" "w" "x" "y" "z" "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" #> [20] "o" "p" "q" "r" "s" "t" "u"