title: creating a summary data frame from long formated data
body: <p>Following this worked example:</p>
  
  <pre><code>case &lt;- c('a','a','a','b','b','c','c','c','c','d','d','e','e')
  ID &lt;- c('aa','bb','zz','aa','cc','ee','ff','gg','kk','aa','kk','cc','dd')
  score &lt;- c(1,1,3,4,2,3,2,2,1,1,3,3,2)
  
  df1 &lt;- data.frame(case, ID, score)
  
  identifier &lt;- c('aa','bb','ff')
  </code></pre>
  
  <p>For each <code>unique</code> <em>case</em>, (that is a,b,c,d...), I want to scan the <code>ID</code> column and see how often we have an <code>identifier</code> value. </p>
  
  <ul>
  <li>So we look into the 3x <code>case==a</code>, then how many times do the <code>ID</code> equal <code>identifier</code>? (in this case 2 times)</li>
  <li>We then look at 2x <code>case==b</code>, and also count how many time <code>ID</code> equal <code>identifier</code>? (in this case 1 times)</li>
  <li>we do this for all <code>unique</code> case's</li>
  </ul>
  
  <p>I have used the following command, but this is for the whole sample, not separated per unique <code>case</code></p>
  
  <pre><code>df1$ID %in% identifier
  </code></pre>
  
  <p>And what I want as a end result is a table, with one column with each unique <code>case</code> and a second column with the number of times <code>ID</code> and <code>identifier</code> were equal.</p>
  
  <p>So I want to loop/automate the process and return a similiar output like:</p>
  
  <pre><code>data.frame(c('a','b','c','d','e'), c(2,1,1,1,0))
  </code></pre>