DescTools (version 0.99.13)

VecRot: Vector Rotation

Description

Shift the elements of a vector in circular mode to the right or to the left by n elements, such that the nth element is the first one of the new vector and the first n-1 elements are appended to the end.

Usage

VecRot(x, n)

Arguments

x
a vector of any type.
n
the number of elements to shift.

Value

  • the shifted vector in the same dimensions as x.

Details

The function will repeat the vector two times and select the appropriate number of elements from the required shift on.

See Also

[, rep

Examples

Run this code
VecRot(c(1,1,0,0,3,4,8), 3)

VecRot(letters[1:10], 3)

Run the code above in your browser using DataCamp Workspace