Re: [R] Count of entries in a row of a data frame

2010-03-18 Thread Phil Spector
Thomas - Two ways that come to mind are apply(dat,1,function(x)sum(x != 0)) and rowSums(dat!=0) (assuming your data frame is named "dat"). - Phil Spector Statistical Computing Facility

[R] Count of entries in a row of a data frame

2010-03-18 Thread Thomas Jensen
Dear R-list, I have data in the following format: Country 1 Country 2Country 3 ... 1 0 10 2 1 02 3 0 10 Now I would like to create a variable that counts every