title: R how to extract the data and its duplicate in a data.frame?
body: <p>Let's say I have the following data.frame:</p>
  
  <pre><code>df &lt;- structure(list(a = c(1, 1, 1, 4), b = c(2, 2, 3, 4), c = c("a", 
  "b", "c", "d")), .Names = c("a", "b", "c"), row.names = c(NA, 
  -4L), class = "data.frame")
  
  &gt; df
  #   a b c
  # 1 1 2 a
  # 2 1 2 b
  # 3 1 3 c
  # 4 4 4 d 
  </code></pre>
  
  <p>if I want to extract get the duplicates considering only columns a and b:</p>
  
  <pre><code>df[duplicated(df[,c(1,2)]),]
  #  a b c
  #2 1 2 b
  </code></pre>
  
  <p>It is then possible to get the duplicates and the data? Which in this case would be:</p>
  
  <pre><code>#1 1 2 a
  #2 1 2 b
  </code></pre>