Learn R Programming

freegroup (version 1.2-0)

shift: Permute elements of a vector in a cycle

Description

Given a vector, permute the elements with a cyclic permutation

Usage

shift(x,i=1)

Value

Returns a vector

Arguments

x

Vector

i

Integer, number of places to permute. Negative values mean to count from the end

Author

Robin K. S. Hankin

Details

This function is that of the magic package, where it is motivated and discussed.

Examples

Run this code

shift(1:9)
shift(1:9,-1)

shift(1:9,2)


Run the code above in your browser using DataLab