title: R - find all unique values among subsets of a data frame
body: <p>I have a data frame with two columns. The first column defines subsets of the data.  I want to find all values in the second column that only appear in one subset in the first column.</p>
  
  <p>For example, from:</p>
  
  <pre><code>df=data.frame(
    data_subsets=rep(LETTERS[1:2],each=5),
    data_values=c(1,2,3,4,5,2,3,4,6,7))
  
  data_subsets data_values
        A           1
        A           2
        A           3
        A           4
        A           5
        B           2
        B           3
        B           4
        B           6
        B           7
  </code></pre>
  
  <p>I would want to extract the following data frame.</p>
  
  <pre><code>data_subsets   data_values
      A              1
      A              5
      B              6
      B              7
  </code></pre>
  
  <p>I have been playing around with <code>duplicated</code> but I just can't seem to make it work.  Any help is appreciated.  There are a number of topics tackling similar problems, I hope I didn't overlook the answer in my searches!</p>
  
  <p><em>EDIT</em></p>
  
  <p>I modified the approach from @Matthew Lundberg of counting the number of elements and extracting from the data frame.  For some reason his approach was not working with the data frame I had, so I came up with this, which is less elegant but gets the job done:</p>
  
  <pre><code>counts=rowSums(do.call("rbind",tapply(df$data_subsets,df$data_values,FUN=table)))
  extract=names(counts)[counts==1]
  df[match(extract,df$data_values),]
  </code></pre>