Hi, Is there a short way of doing this?
I have the following table in R: 12.0 0.5 0.6 0.2 0 0 12.3 1.2 0.8 0 0 0 13.1 0 1.2 0 0 0 10.1 0 0 0 1.3 0 10.2 1.3 1.2 0.9 0 1.3 So I have 5 rows and 6 columns. For each row, I want to count the number of times that the value is greater than 1 (FOR COLUMNS 2 TO 4). I have the following R code. count=numeric() for (i in 1:5) { count[i]=sum(c5[i,2:4]>0) } The result is > count [1] 3 2 1 0 3 Is there a short way of doing this (instead of doing the loop)? Thank you. -Valerie [[alternative HTML version deleted]]
______________________________________________ R-help@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.