title: R data.table filtering on group size
body: <p>I am trying to find all the records in my <code>data.table</code> for which there is more than one row with value <em>v</em> in field <em>f</em>.</p>
  
  <p>For instance, we can use this data:</p>
  
  <pre><code>dt &lt;- data.table(f1=c(1,2,3,4,5), f2=c(1,1,2,3,3))
  </code></pre>
  
  <p>If looking for that property in field <code>f2</code>, we'd get (note the absence of the (3,2) tuple)</p>
  
  <pre><code>    f1 f2
  1:  1  1
  2:  2  1
  3:  4  3
  4:  5  3  
  </code></pre>
  
  <p>My first guess was <code>dt[.N&gt;2,list(.N),by=f2]</code>, but that actually keeps entries with <code>.N==1</code>.</p>
  
  <pre><code>dt[.N&gt;2,list(.N),by=f2]
     f2 N
  1:  1 2
  2:  2 1
  3:  3 2
  </code></pre>
  
  <p>The other easy guess, <code>dt[duplicated(dt$f2)]</code>, doesn't do the trick, as it keeps one of the 'duplicates' out of the results.</p>
  
  <pre><code>dt[duplicated(dt$f2)]
     f1 f2
  1:  2  1
  2:  5  3
  </code></pre>
  
  <p>So how can I get this done?</p>
  
  <p><strong>Edited to add example</strong></p>