title: Subset with unique cases, based on multiple columns
body: <p>I'd like to subset a dataframe to include only rows that have unique combinations of three columns. My situation is similar to the one presented in <a href="https://stackoverflow.com/questions/2900510/r-equivalent-of-select-distinct-on-two-or-more-fields-variables">this</a> question, but I'd like to preserve the other columns in my data as well. Here's my example:</p>
  
  <pre><code>&gt; df
    v1  v2  v3   v4  v5
  1  7   1   A  100  98 
  2  7   2   A   98  97
  3  8   1   C   NA  80
  4  8   1   C   78  75
  5  8   1   C   50  62
  6  9   3   C   75  75
  </code></pre>
  
  <p>The requested output would be something like this, where I'm looking for unique cases based on v1, v2, and v3 only:</p>
  
  <pre><code>&gt; df.new
    v1  v2  v3   v4  v5
  1  7   1   A  100  98 
  2  7   2   A   98  97
  3  8   1   C   NA  80
  6  9   3   C   75  75
  </code></pre>
  
  <p>If I could recover the non-unique rows that would be great too:</p>
  
  <pre><code>&gt; df.dupes
    v1  v2  v3   v4  v5
  3  8   1   C   NA  80
  4  8   1   C   78  75
  5  8   1   C   50  62
  </code></pre>
  
  <p>I saw a related question for how to do this in sql (<a href="https://stackoverflow.com/questions/10816696/how-to-get-get-unique-records-based-on-multiple-columns-from-a-table">here</a>), but I can't get this in R. I'm sure it's simple but messing with unique() and subset() hasn't been fruitful. Thanks in advance.</p>