[Solved] Find and count “0” values in each series(column) in R


If I understand correctly, you want to count how many 0 values you have in each column?

If so, you can use apply function for each of the columns:

data <- data.frame( a = c(1,2,0,3), b = c(0,0,0,2) )
apply( data , 2 , function(x) sum ( x == 0 ) )
a b 
1 3 

6

solved Find and count “0” values in each series(column) in R