title: R compare data frames by differences in occurrences of elements in character variable
body: <p>1Given two data frames how can one find the rows in which the number of occurrences of elements in a variable/column are different between the data frames. For instance, given the two data frames:</p>
  
  <pre><code>df1 &lt;- data.frame(
      id=c(1,2,3,4),
      score=c("AA","BB","BB","BA"))
  
  
  df2 &lt;- data.frame(
      id=c(1,2,3,4,5,6),
      score=c("AA","BB","BB","BB","BA","BC"))
  </code></pre>
  
  <p>The number of occurences of each string in score can be found and added row-wise to df1 by e.g.</p>
  
  <pre><code>library('dplyr')
  df1 &lt;- join(df1, ddply(df1, .(score), 'nrow'))
  </code></pre>
  
  <p>But how can I get a subset of df1 that contains only rows where scores with a different occurrence in df2 ? I would expect a result consisting of rows 2 and 3 (id 2 and 3) since "BB" occurs 2 times in df1 and 3 in df2, while "AA" and "BA" both occur 1 time in each df. Obviously, another result is expected if we asked for df2 in df1</p>