Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

recurse

Recursively apply a permutation


Description

Recursively apply a permutation to a vector an arbitrary number of times. Negative times mean apply the inverse permutation.

Usage

recurse(perm, i, start = seq_along(perm))

Arguments

perm

Permutation (integers 1 to length(start) in some order)

start

Start vector to be permuted

i

Number of times to apply the permutation. i=0 gives start by definition and negative values use the inverse permutation

Author(s)

Robin K. S. Hankin

See Also

Examples

n <- 15
noquote(recurse(start=letters[1:n],perm=shift(1:n),i=0))
noquote(recurse(start=letters[1:n],perm=shift(1:n),i=1))
noquote(recurse(start=letters[1:n],perm=shift(1:n),i=2))

noquote(recurse(start=letters[1:n],perm=sample(n),i=1))
noquote(recurse(start=letters[1:n],perm=sample(n),i=2))

magic

Create and Investigate Magic Squares

v1.5-9
GPL-2
Authors
Robin K. S. Hankin
Initial release
2018-09-14

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.