title: Match Vector to multiple columns, return index and corresponding value in other column
body: <p>I have a dataframe:</p>
  
  <pre><code>a = c(1, 2, 3, 4, 9) 
  b = c(5, 6, 7, 8, 10) 
  c = c('xx','yy','zz', 'kk', 'bb') 
  df = data.frame(a, b, c) 
  
  &gt; df
    a  b  c
  1 1  5 xx
  2 2  6 yy
  3 3  7 zz
  4 4  8 kk
  5 9 10 bb
  </code></pre>
  
  <p>And an integer vector:</p>
  
  <pre><code>&gt; names
  [1] 1 3 5 8
  Levels: 1 3 5 8
  </code></pre>
  
  <p>I can return the index in <code>df</code> where <code>names</code> matches column <code>a</code> or <code>b</code>, using <code>match</code>:</p>
  
  <pre><code>&gt; match(names, df$a)
  [1]  1  3 NA NA
  &gt; match(names, df$b)
  [1] NA NA  1  4
  </code></pre>
  
  <p>I want to combine the above two statements, and for the indexes returned, return the corresponding value in column c, for that particular index, so that my output is:</p>
  
  <pre><code>out = [1] "xx" "zz" "xx" "kk"
  </code></pre>
  
  <p>I tried to do:</p>
  
  <pre><code>&gt; df$c[match(names, df$a) | match(names, df$b)]
  [1] "xx" "yy" "zz" "kk" "bb"
  </code></pre>
  
  <p>But as this becomes a boolean test, it does not function as required.</p>
  
  <p>How can I achieve my desired output? Many thanks.</p>