Learn R Programming

permutations (version 1.1-6)

keepcyc: Keep or discard some cycles of a permutation

Description

Given a permutation and a function that returns a Boolean specifying whether a cycle is acceptable, return a permutation retaining only the acceptable cycles.

Usage

keepcyc(a, func, ...)

Value

Returns a permutation in cycle form

Arguments

a

Permutation, coerced to cycle

func

Function to be applied to each element of a

...

Further arguments to fun()

Author

Robin K. S. Hankin

See Also

allcyc

Examples

Run this code

keepcyc(rgivenshape(10,2:8),function(x){length(x) == 2})  # retains just transpositions
keepcyc(megaminx,function(x){any(x == 100)})              # retains just cycles modifying facet #100
keepcyc(rperm(100),function(x){max(x)-min(x) < 3})        # retains just cycles with range<3

f <- function(x,p){all(xp)}                  # keep only cycles with all entries either
keepcyc(rgivenshape(9,rep(2:3,9)),f,p=20)                 #  all < 20 or all >20

Run the code above in your browser using DataLab