[R] function for all binomial combinations?

Michael Wolf mwolf at iew.uzh.ch
Thu Nov 22 19:09:02 CET 2007


Dear all,

Is there a function that computes all binomial combinations.
I am aware of the function "choose(n, k)" which computes the
number of such combinations, but not the actual combinations
themselves, e.g.:

 > choose(4, 2)
[1] 6

So I am looking for function that would give me the following
matrix as output, say:

 > function(4, 2)
      [,1] [,2]
[1,]    1    2
[2,]    1    3
[3,]    1    4
[4,]    2    3
[5,]    2    4
[6,]    3    4

Matlab has such function, but I could not find one in R.

Please also reply directly to me: mwolf at iew.uzh.ch.

Thanks much,
Michael



More information about the R-help mailing list