[R] code to find all distinct subsets of size r from a set of size n

Dale Steele dale.w.steele at gmail.com
Fri Mar 13 13:35:59 CET 2009


I'm doing a permutation test and need to efficiently generate all
distinct subsets of size r from a set of size n.  P 138 of MASS (4th
ed) notes that  "The code to generate this efficiently is in the
scripts".  I was unable to find this code on quick inspection of the
\library\MASS\scripts file for Chapter 5 and 'subsets' is not a
function in MASS.

I did find this problem is discussed in RNews, Programmer's Niche
1(1):27 - 30 and RNews, 1(2):29-31.  Is there function in 'base'  R or
other package to do this?  Thanks.  --Dale




More information about the R-help mailing list