title: R Aggregate and count of not null
body: <p>I have the following data table</p>
  
  <pre><code>PIECE   SAMPLE  QC_CODE
  1       1       1
  2       1       NA  
  3       2       2
  4       2       4
  5       2       NA
  6       3       6
  7       3       3
  8       3       NA
  9       4       6
  10      4       NA
  </code></pre>
  
  <p>and I would like to count the number of qc_code in each sample and return an output like this</p>
  
  <pre><code>SAMPLE    SAMPLE_SIZE    QC_CODE_COUNT
  1         2              1
  2         3              2
  3         3              2
  4         2              1
  </code></pre>
  
  <p>Where sample size is the count of pieces in each sample, and qc_code_count is the count of al qc_code that are no NA.</p>
  
  <p>How would I go about this in R  </p>