powered by
Function capply() means “cycle apply” and is modelled on lapply(). It applies a function to every element in the cycles of its argument.
capply()
lapply()
capply(X, fun, ...)
Returns a permutation in cycle form
Permutation, coerced to cycle
Function to be applied to each element of X
X
Further arguments to fun()
fun()
Robin K. S. Hankin
This function is just a convenience wrapper really.
(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
Run the code above in your browser using DataLab