title: How to count number of particular values
body: <p>My data looks like this:</p>
  
  <pre><code>ID CO MV  
  1   0  1      
  1   5  0   
  1   0  1      
  1   9  0      
  1   8  0      
  1   0  1      
  2  69  0       
  2   0  1      
  2   8  0      
  2   0  1      
  2  78  0      
  2  53  0       
  2   0  1      
  2   3  0      
  3  54  0      
  3   0  1      
  3   8  0      
  3  90  0      
  3   0  1      
  3  56  0      
  4   0  1      
  4  56  0      
  4   0  1      
  4  45  0      
  4   0  1      
  4  34  0      
  4  31  0      
  4   0  1      
  4  45  0      
  5   0  1      
  5   0  1      
  5  67  0  
  </code></pre>
  
  <p>I want it to look like this:</p>
  
  <pre><code>ID CO MV  CONUM
  1   0  1      3 
  1   5  0      3
  1   0  1      3
  1   9  0      3
  1   8  0      3
  1   0  1      3
  2  69  0      5 
  2   0  1      5
  2   8  0      5
  2   0  1      5
  2  78  0      5
  2  53  0      5 
  2   0  1      5
  2   3  0      5
  3  54  0      4
  3   0  1      4
  3   8  0      4
  3  90  0      4
  3   0  1      4
  3  56  0      4
  4   0  1      5
  4  56  0      5
  4   0  1      5
  4  45  0      5
  4   0  1      5
  4  34  0      5
  4  31  0      5
  4   0  1      5
  4  45  0      5
  5   0  1      1
  5   0  1      1
  5  67  0      1
  </code></pre>
  
  <p>I want to create a column CONUM which is the total number of values other than zero in the CO column for each value in the ID column. So for example the CO column for ID 1 has 3 values other than zero, therefore the corresponding values in CONUM column is 3. The MV column is 0 if CO column has a value and 1 if CO column is 0. So another way to accomplish creating the CONUM column would be to count the number of zeros per ID . It would be great if you could help me with the r code to accomplish this. Thanks.</p>