title: R - Compare values in two columns in different rows
body: <p>I have a dataframe <code>df</code> as seen below with two features, a departing city and an arrival city. Every two rows information is stored about a going and a return flight. </p>
  
  <pre><code>  Departure Arrival
  1    A          B
  2    B          A
  3    F          G
  4    G          F
  5    U          V
  6    V          U
  7    K          L
  8    K          L
  </code></pre>
  
  <p>There is some inconsistency in the data where the same flight is repeated as it can be seen in the last two rows.</p>
  
  <p>How is it possible to compare for every two rows the departure city of the first row and the arrival city of the second row, and keep the ones that are equal.
  The dataset is very big and of course a for-loop is not considered an option.</p>
  
  <p>Thank you in advance.</p>