Displaying 1 result from an estimated 1 matches for "wifht".
Did you mean:
wiaht
2006 Aug 09
1
Combinations question
I need to generate a {0,1} matrix wifht nCr rows and n columns. The rows of the matrix will consist of all possible combinations containing r ones.
My clumsy attempt for n = 6 and r = 3 is
X <- expand.grid(c(1,0),c(1,0),c(1,0),c(1,0),c(1,0),c(1,0))
Y <- X[rowSums(X)==3,]
I can genralize this in a function but the result is quite...