I have a question about counting zeros per row. I have a dataframe like this:
a = c(1,2,3,4,5,6,0,2,5) b = c(0,0,0,2,6,7,0,0,0) c = c(0,5,2,7,3,1,0,3,0) d =
It's not only possible, but very easy:
DF[rowSums(DF == 0) <= 4, ]
You could also use apply:
apply
DF[apply(DF == 0, 1, sum) <= 4, ]