title: Remove rows in R using data.table
body: <p><strong>df:-</strong></p>
  
  <pre><code>Date    Name  Salary 
  Q1 2015 ABC   $10
  Q2 2015 ABC   $11
  Q3 2015 ABC   $15
  Q1 2015 XYZ   $25
  Q2 2015 XYZ   $20
  </code></pre>
  
  <p>I want to remove the rows from the data whose total frequency is less than 3. For e.g. XYZ have a frequency of 2 and so I want to remove row 4 and 5.</p>
  
  <pre><code>test &lt;- setDT(df)[,.I[.N&gt;2],by=Name]
  </code></pre>
  
  <p>Output:-</p>
  
  <pre><code>&gt; test
     Name V1
  1:  ABC  1
  2:  ABC  2
  3:  ABC  3
  </code></pre>
  
  <p>Filtering is done correctly but I don't get the whole data set, I only get the Name column in the output. </p>