Learn R Programming

container (version 1.0.5)

rotate: Rotate Elements

Description

Rotate all elements n steps to the right. If n is negative, rotate to the left.

Usage

rotate(x, n = 1L)

ref_rotate(x, n = 1L)

# S3 method for Deque rotate(x, n = 1L)

# S3 method for Deque ref_rotate(x, n = 1L)

Value

For Deque returns the rotated Deque() object.

Arguments

x

any R object.

n

integer number of steps to rotate

Details

While rotate uses copy semantics, ref_rotate works by reference, that is, rotates in place on the original object.

Examples

Run this code
d = deque(1, 2, 3, 4)
rotate(d)
rotate(d, n = 2)

Run the code above in your browser using DataLab