Re: [R] count number of TRUEs in each row

From: Peter Langfelder <>
Date: Sun, 10 Apr 2011 14:43:00 -0700

On Sun, Apr 10, 2011 at 2:24 PM, Wendy <> wrote:
> 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]


Peter mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Sun 10 Apr 2011 - 21:47:56 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 Sun 10 Apr 2011 - 22:20:30 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive