title: R Find string matches multiple columns, and choose most right column match
body: <p>I have a problem for which I can't find a solution..
  This is some example data:</p>
  
  <pre><code>df&lt;-data.frame(ID1=c("A10","B73","B73","D20"),
                 ID2=c(NA,"B4","C05","D100"),
                 ID3=c(NA,"B20","C30","D41"),
                 ID4=c(NA,NA,"B40","D0"),
                 ID5=c(NA,NA,NA,"D10"),
                 Score=c(15,376,102,30))
  &gt;df
    ID1  ID2  ID3  ID4  ID5 Score
  1 A10 &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt;    15
  2 B73   B4  B20 &lt;NA&gt; &lt;NA&gt;   376
  3 B73  C05  C30  B40 &lt;NA&gt;   102
  4 D20 D100  D41   D0  D10    30
  </code></pre>
  
  <p>I also have data with different ID numbers that match some of the <code>ID</code>'s in <code>df</code> and matching <code>Score</code>. It looks like this:</p>
  
  <pre><code>df_match&lt;-data.frame(ID_Match=c("A10","B4","B20","E20","A355","D0","C30"),
                 Score_Match=c(30,55,200,120,113,23,98))
  &gt;df_match
    ID_Match Score_Match
  1      A10          30
  2       B4          55
  3      B20         200
  4      E20         120
  5     A355         113
  6       D0          23
  7      C30          98
  </code></pre>
  
  <p>What I want to do is for R to search for ID matches in <code>df</code> and if there is a match, put the matching <code>ID</code> en <code>Score</code> in a new column. If one row contains multiple ID matches, then pick the ID match of the most right column. So it would look like this:</p>
  
  <pre><code>&gt; df_Final
    ID1  ID2  ID3  ID4  ID5 Score ID_Match Score_Match
  1 A10 &lt;NA&gt; &lt;NA&gt; &lt;NA&gt; &lt;NA&gt;    15      A10          30
  2 B73   B4  B20 &lt;NA&gt; &lt;NA&gt;   376      B20         200
  3 B73  C05  C30  B40 &lt;NA&gt;   102      C30          98
  4 D20 D100  D41   D0  D10    30       D0          23
  </code></pre>
  
  <p>I have found answers like:</p>
  
  <pre><code>IDColumns &lt;- 1:5
  d &lt;- df[,IDColumns] == "ID"
  </code></pre>
  
  <p>or</p>
  
  <pre><code>df$Check &lt;- (rowSums(df[,startsWith(names(df),"ID")]=="ID") &gt;= 1)
  </code></pre>
  
  <p>But most answers I found where only searching for a match of one specific string. Could someone help me?</p>