title: Deleting rows based on a calculated criteria in R
body: <p>I conducted an analysis for some M&amp;A-Deals. My current output looks like this:</p>
  <pre><code>Deal-Nr | Event-Date  | Target-Nation | CAR  | SIC
  ----------------------------------------------------
  1       |  01-01-1999 | Italy         | 5.1% | 201
  2       |  02-01-1999 | Germany       | 2.3% | 202
  3       |  06-01-1999 | Spain         | 1.5% | 201
  4       |  10-09-1999 | Germany       | 0.3% | 201
  5       |  15-09-1999 | UK            | 1.1% | 201
  6       |  25-10-2000 | Spain         | 0.8% | 201
  
  </code></pre>
  <p>However, for my final analysis I want to exclude all deals within the same SIC-Code, which do not have at least 180 trading days between them. So in this case, I would want to exclude my deal 3 from the analysis (as they have the same SIC-code and do not have 180 days between them). Then the code should continue and check the next deal within that SIC-Code industry and remove (&lt;180 days) or keep it (&gt;180 days). This should be done for all the different SIC codes in my analysis.</p>
  <p>As I'm rather new in R, I'm reaching out for help. Thank you so much for your support.</p>
  <p>Edit:
  As indicated below I provide some further information. I'm interested in the deals that are in the same SIC-Code and &gt;180 days apart. This would mean in the table to remove row (3) and row (5). If one deal is more than 180 days apart the subsequent dates should be checked.</p>