title: In R, remove rows where subtraction of values between contiguous values in same column excede a value
body: <p>I have a data frame in R consisting in 5 columns and 30000 rows. One column, called "pos", has this kind of values sorted in ascending order:</p>
  
  <pre><code>pos
  
  785989
  888659
  918573
  949608
  990417
  </code></pre>
  
  <p>I would like to remove all rows where the difference between a "x" value in "pos" (in a "n" row) and the anterior value in the "n-1" row or the difference between the posterior value in "n+1" row and "x" is greater than, lets say, 100000. Eg: in the input example, 888659-785989 = 102670 > 100000, therefore rows containing 888659 and 785989 values should be removed. </p>
  
  <p>Thanks for your help !</p>