title: Selecting rows where a column changes by more than a threshold
body: <p>I have a dataframe containing three columns, where the first is an ID, the second denotes a year and the third column is the value associated with the ID in that year:</p>
  
  <pre><code>df.in &lt;- data.frame("id"=c(1,1,1,1,1, 2,2,2,2,2,2, 3,3,3,3,3,3,3),
                      "yr"=c(2005,2006,2007,2008,2010, 2001,2002,2003,2006,2008,2009, 2001, 2002,2003,2004,2005,2007,2009),
                      "val"=c(5,6,7,8,10, 1,2,3,6,8,10, 1,2,3,4,5,7,9))
  </code></pre>
  
  <p>I'd like to remove rows where the year has a gap with the previous year which is larger than 1. In other words, I want to keep only those rows in the data where the years follow each other in increments of 1:</p>
  
  <pre><code>df.out &lt;- data.frame("id"=c(1,1,1,1, 2,2,2, 3,3,3,3,3),
                       "yr"=c(2005,2006,2007,2008, 2001,2002,2003,2001, 2002,2003,2004,2005),
                       "val"=c(5,6,7,8, 1,2,3, 1,2,3,4,5))
  </code></pre>
  
  <p>Is there a way to do this in R using <code>dplyr</code>? If possible, I'd like a dataframe containing all discarded years as well:</p>
  
  <pre><code>df.discard &lt;- data.frame("id"=c(1, 2,2, 3,3),
                           "yr"=c(2010, 2006, 2008,2009, 2007,2009),
                           "val"=c(10, 6, 8,10, 7,9))
  </code></pre>