[R] all possible subsets of r out of n
    Yuelin Li 
    yuelin at mail.med.upenn.edu
       
    Wed Aug 28 18:28:28 CEST 2002
    
    
  
Has anyone written a function that returns all possible
subsets of r elements out of a vector that contains n
elements?  I have not been able to find an answer in the FAQ
or the archives.
Say I have a vector: letters[1:10].  I want to get a matrix
of 120 rows that contains all possible subsets of 3 letters
out of the 10.  And I would like to be able to generalize to
any r out of n, like function(x=letters[1:10], r=3) that
returns:
a, b, c
a, b, d
a, b, e
...
etc.
Many thanks in advance,
- Yuelin Li.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
    
    
More information about the R-help
mailing list