[R] count number of TRUEs in each row

From: Wendy <wendy2.qiao_at_gmail.com>
Date: Sun, 10 Apr 2011 14:24:09 -0700 (PDT)


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.

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Sun 10 Apr 2011 - 21:28:58 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 11 Apr 2011 - 01:40:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive