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

2011-04-10 Thread Hasan Diwan
Ms Qiao, On 10 April 2011 14:24, Wendy wrote: > 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

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

2011-04-10 Thread Tóth Dénes
Hi Wendy, try this: Z <- matrix(runif(1000)>0.5,10,100) rowSums(Z) HTH, Denes > 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 t

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

2011-04-10 Thread Peter Langfelder
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. > >  

[R] count number of TRUEs in each row

2011-04-10 Thread Wendy
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