[R] combinations
Michaell Taylor
pols1oh at bestweb.net
Thu Nov 7 20:51:42 CET 2002
I need to construct all possible combinations of an vector of length N taken
X at a time for simulation purposes. Taking a a small vector as an example:
>input <- c('a','b','c','d')
>somefunction(input)
a,b,c
a,b,d
a,c,d
b,c,d
my only solution thus far is:
somefunction <- function(x){
...a series of grotesque and horribly inefficient loops
deleted to save face.
}
For my purposes, N=20 and X=5, meaning there are about 15k combinations.
I assumed this might be a common problem, but I am coming up empty on my searches
of the usual suspect web sites.
Thanks in advance for any pointers anyone may have.
Michaell
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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