You just need to use the apply
function:
## Example Data
dd = data.frame(col1 = c(0, .3, 0), col2=c(0, 1, 0),
col3=c(0.4, 0, 0.8))
apply(dd, 1, function(i) sum(i > 0))
So to add this too your existing data frame:
dd$col4 = apply(dd, 1, function(i) sum(i > 0))
Alternatively, we could convert the data frame to logical values then use rowSums
rowSums(dd > 0)