Learn R Programming

rosario (version 0.1.0)

vec_permutation: Cyclic permutation (rotate) a numeric vector

Description

Returns a cyclic shift of numvec so that position x becomes the first element and the order wraps around the end.

Usage

vec_permutation(numvec, x = 1)

Value

A numeric vector of the same length as numvec, rotated so that numvec[x] is first.

Arguments

numvec

Numeric vector representing an ordered cycle.

x

Integer (1-based) index of the new starting position.

Examples

Run this code
vec_permutation(1:6, 4)  # 4 5 6 1 2 3

Run the code above in your browser using DataLab