Re: [R] A combinatorial task. How to get rid of loops

2007-08-02 Thread Uwe Ligges
Serguei Kaniovski wrote: > Dear List, > > I am looking for a faster way of accomplishing this: > > # n is an integer larger than two > n <- 3 > > # matrix of 2^n binary outcomes > bmat <- as.matrix(expand.grid( rep( list(1:0), n))[, n:1]) > > # I would like to know which rows of "bmat" have "

[R] A combinatorial task. How to get rid of loops

2007-08-02 Thread Serguei Kaniovski
Dear List, I am looking for a faster way of accomplishing this: # n is an integer larger than two n <- 3 # matrix of 2^n binary outcomes bmat <- as.matrix(expand.grid( rep( list(1:0), n))[, n:1]) # I would like to know which rows of "bmat" have "1" in the "i" and "j" coordinates, so for n=3 in