Re: [R] frequency count by row

2012-03-06 Thread R. Michael Weylandt
Or perhaps faster but less general: rowSums(mydata != 0) Michael On Tue, Mar 6, 2012 at 12:56 PM, Sarah Goslee wrote: > A reproducible example would be helpful, but lacking that > here's some untested code. If your data frame has NA values, > those will also need to be dealt with. > > apply(myd

Re: [R] frequency count by row

2012-03-06 Thread Sarah Goslee
A reproducible example would be helpful, but lacking that here's some untested code. If your data frame has NA values, those will also need to be dealt with. apply(mydata, 1, function(x)sum(x != 0)) Sarah On Tue, Mar 6, 2012 at 12:03 PM, mari681 wrote: > I feel this is a very easy thing but I'

[R] frequency count by row

2012-03-06 Thread mari681
I feel this is a very easy thing but I've never done it before and it is getting frustrating. I have a big data.frame (1445846 rows, 15 col) that looks like this: V1 V2 V3 V4 V5 1home sisterbrother chair 0 2cat