keepcyc | R Documentation |
Given a permutation and a function that returns a Boolean specifying whether a cycle is acceptable, return a permutation retaining only the acceptable cycles.
keepcyc(a, func, ...)
a |
Permutation, coerced to cycle |
func |
Function to be applied to each element of |
... |
Further arguments to |
Returns a permutation in cycle form
Function keepcyc()
is idempotent.
Robin K. S. Hankin
allcyc
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(x<p) || all(x>p)} # keep only cycles with all entries either
keepcyc(rgivenshape(9,rep(2:3,9)),f,p=20) # all < 20 or all >20
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.