Skip to content
Prev 20558 / 63421 Next

combn(n, k, ...) and all its re-inventions

Martin Maechler <maechler at stat.math.ethz.ch> writes:
While you're in there... combn() has a nice feature that you can apply
a function to each combination, which can be quite useful (and fun) if
you're demonstrating permutation tests:
[1] 0.04072398


However, combn() does its work in sapply() style: First create a list,
then simplify. As this quickly becomes a rather *long* list (e.g., a
slightly larger case with choose(29, 14)==77558760 combinations kills
R for me on a 2GB 64 bit machine), it might be desirable to have an option,
"assume.scalar" or so, to specify that the function always returns a
single scalar.