title: Joining two data frames by sequential column matching
body: <p>Let's say I have two data frames like so:</p>
  <pre><code>test_1 = game_df = read.table(text = &quot;id winner_name
  1 Jon
  2 Bob
  3 Lucas
  4 Marcus
  5 Toad
  6 Donkey&quot;, header = T)
  
  test_2 = game_df = read.table(text = &quot;id_1 id_2 loser_name
  9 1 Henry
  2 2 George
  3 3 Bagel
  4 4 Cat
  5 5 Giraffe
  7 6 Monkey&quot;, header = T)
  </code></pre>
  <p>What I want to do is to first is to <code>left_join</code> <code>test_1</code> on the <code>id = id_=1</code> match like so:</p>
  <pre><code>test_1 %&gt;% left_join(test_2 %&gt;% select(id_1, loser_name), by = c('id' = 'id_1'))
  </code></pre>
  <p>There will be certain NA matches (John, and Donkey)</p>
  <pre><code>  id winner_name loser_name
  1  1         Jon       &lt;NA&gt;
  2  2         Bob     George
  3  3       Lucas      Bagel
  4  4      Marcus        Cat
  5  5        Toad    Giraffe
  6  6      Donkey       &lt;NA&gt;
  </code></pre>
  <p>And then I'd like to use <code>id_2</code> as the matching column to fill the NA's, so I currently do something like this:</p>
  <pre><code>test_1 %&gt;% left_join(test_2 %&gt;% select(id_1, loser_name), by = c('id' = 'id_1')) %&gt;%
    left_join(test_2 %&gt;% select(id_2, loser_name), by = c('id' = 'id_2'))
  
    id winner_name loser_name.x loser_name.y
  1  1         Jon         &lt;NA&gt;        Henry
  2  2         Bob       George       George
  3  3       Lucas        Bagel        Bagel
  4  4      Marcus          Cat          Cat
  5  5        Toad      Giraffe      Giraffe
  6  6      Donkey         &lt;NA&gt;       Monkey
  </code></pre>
  <p>This seems to work, but it generates a bunch of duplicate columns with <code>x</code> and <code>y</code> suffixes. In my actual dataset, I have to go through this conditional matching approach through a ton of <code>id</code> matches, so it will generate a large number of duplicate columns, that I then have to manually deselect and rename.</p>
  <p>The issue is that there are hundreds of columns in the actual <code>test_2</code> data.frame (loser_name, loser_country, loser_elo, loser_record, loser_win_rate), etc., so I'd need to manually specify the name and the columns to coalesce for each one. Furthermore, because I do this sequential id matching with more than one id, I'll have loser_name.x, loser_name.y, loser_name.z, and I don't know in advance how many suffixes there will be for each column.</p>
  <p>Is there a simpler approach to this?</p>