[R] count number of TRUEs in each row

Wendy wendy2.qiao at gmail.com
Sun Apr 10 23:24:09 CEST 2011


Hi all, 

I have a huge matrix of TRUE/FALSE table like following, and I want to count
the number of TRUEs in each row. Instead of looping through each row and do
length(Z[Z==TRUE]), I am wondering if there is an easier way of doing this. 

       [,1]   [,2]    [,3]
[1,]TRUE FALSE FALSE
[2,]FALSE TRUE TRUE

Thank you in advance.
Wendy

--
View this message in context: http://r.789695.n4.nabble.com/count-number-of-TRUEs-in-each-row-tp3440486p3440486.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list