title: Data Split based on a logical relationship in R
body: <p>I have a dataset with historical data and I want to break it into two sets:</p>
  
  <ol>
  <li>The set of IDs that I have their data for at least two consecutive years.</li>
  <li>It's complement, i.e, the set of IDs that I have one or more year of data from them but in nonconsecutive years.</li>
  </ol>
  
  <p>For example, let's take data set A:</p>
  
  <pre><code>A =
  ID    Year    X   Y
  1     2010    2   3
  1     2012    4   0
  2     2011    4   3
  2     2012    2   2
  3     2010    3   1
  3     2012    2   1
  3     2013    0   3
  </code></pre>
  
  <p>I want to get the set B:</p>
  
  <pre><code>B = 
  ID    Year    X   Y
  2     2011    4   3
  2     2012    2   2
  3     2012    2   1
  3     2013    0   3
  
  B'=
  ID    Year    X   Y
  1     2010    2   3
  1     2012    4   0
  3     2010    3   1
  </code></pre>
  
  <p>Note that ID 3 is shown in both <code>B</code> and <code>B'</code> because it has records of consecutive years and a single year.</p>
  
  <p>I do not have to do this in R, I can use Python as well. Any help would be appreciated.</p>