capply | R Documentation |
Function capply()
means “cycle apply” and is modelled on
lapply()
. It applies a function to every element in the cycles
of its argument.
capply(X, fun, ...)
X |
Permutation, coerced to cycle |
fun |
Function to be applied to each element of |
... |
Further arguments to |
This function is just a convenience wrapper really.
Returns a permutation in cycle form
Robin K. S. Hankin
(x <- rperm()) capply(x,function(x){x+100}) capply(x,rev) all(is.id(capply(x,rev)*x)) # should be TRUE capply(rcyc(20,5,9),order) capply(rcyc(20,5,9),sample) # still 5-cycles
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.