Skip to contents

Shift the elements of a an object to the left, cycling elements to the end of the object as they are removed from the start. Negative values shift to the right.

Usage

rotate(x, n, ...)

Arguments

x

object to be rotated.

n

number of positions to rotate (left); negative to rotate right.

...

passed to methods.

Value

a new object with elements shifted left by `n` positions

Examples

rotate(LETTERS[1:5])
#> [1] "B" "C" "D" "E" "A"
rotate(LETTERS[1:5], 2)
#> [1] "C" "D" "E" "A" "B"
rotate(LETTERS[1:5], -1)
#> [1] "E" "A" "B" "C" "D"