Re: [R] Discarding a matrix based on the rowSums value

2011-11-23 Thread R. Michael Weylandt
If it's working you are just getting lucky: this is the syntax you want/need: if(any(rowSums(m) == N.1s)) flag <- TRUE You test each of the rowSums and then you check if any of the results are true. That warning came up because R has a way to convert numbers to T/F values but it hesitates bec

Re: [R] Discarding a matrix based on the rowSums value

2011-11-21 Thread David Winsemius
On Nov 21, 2011, at 10:58 AM, Juan Antonio Balbuena wrote: Hello I would appreciate your help on the followig. I want to generate random binary matrices but I need to discard those with all-1 rows. That is, for a 10x10 matrix with five 1's [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]

Re: [R] Discarding a matrix based on the rowSums value

2011-11-21 Thread Sarah Goslee
Hi, You write below: > What I specifically need is a way to write "If any of the elements of the > SUMROW vector == N.1s then flag <-true else flag<-false". And in fact, ?any is just what you need, as you said. any(SUMROW == N.1s) should do the trick. Sarah On Mon, Nov 21, 2011 at 10:58 AM, J

Re: [R] Discarding a matrix based on the rowSums value

2011-11-21 Thread R. Michael Weylandt
any() Michael On Mon, Nov 21, 2011 at 10:58 AM, Juan Antonio Balbuena wrote: > Hello > I would appreciate your help on the followig. I want to generate random > binary matrices but I need to discard those with all-1 rows. That is, for a > 10x10 matrix with five 1's > >      [,1] [,2] [,3] [,4] [

[R] Discarding a matrix based on the rowSums value

2011-11-21 Thread Juan Antonio Balbuena
Hello I would appreciate your help on the followig. I want to generate random binary matrices but I need to discard those with all-1 rows. That is, for a 10x10 matrix with five 1's [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,]000000000 1 [2