title: R: compare the next two values in a vector with each other (without looping if possible)
body: <p>I have a vector like this:</p>
  
  <pre><code>10  7  7 10  7 10  7 10 10  7 10 10  7  7 10 10  7 10  7  7 10  7 10
  </code></pre>
  
  <p>I want to compare the entries of the vector in pairs: e.g. the first entry with the second, the third with the fourth until in a pair I have two equal entries.
  In this example two equal values occur for the first time in the sixth pair or in other words the 11th and 12th values are equal.
  IMPORTANT is now that I want to have the index of the 11th row and continue with the comparison between the 12th and 13th row.</p>
  
  <p>Is there a good way to do this (I would prefer to do it without looping)?</p>
  
  <p>EDIT:
  I really didn't explain myself clear enough. When a pair has equal values I would like to delete the first entry of these two values. So the indices of the pairs are not known from the start.
  In the above example, the desired output would be:</p>
  
  <pre><code>10  7  7 10  7 10  7 10 10  7 10  7  7 10 10  7 10  7  7 10  7 10
  </code></pre>
  
  <p>and the index of the row which has been deleted:</p>
  
  <pre><code>11
  </code></pre>
  
  <p>In this case only one row had to be deleted that all pairs consist of a 7 and a 10.</p>