title: How to replace values in a column of a dataframe with the values of another column based on matches to a third column?
body: <p>I have a problem when trying to convert the values of a dataframe with four variables into the values of a specific column in another dataframe with two variables based on matches between a third column.</p>
  <p>In a dataframe df1 I have a meta_# which corresponds to an iso_# represented in the same row as the meta_#. I want the corresponding iso_# to replace the meta_# in df2 when the meta_# in the dataframes matches.</p>
  <p>With a simplified dataset e.g.:</p>
  <p>When df1$V1 matches with the value of any of the values in df2$V1, df2$V2, df2$V3 and df2$V4 I want the values in df2 to be replaced with the value of df1$V2 in the same row as the respective match</p>
  <p>df1</p>
  <pre><code>     V1      V2
  1 meta_123 iso_321
  2 meta_234 iso_987
  3 meta_345 iso_876
  4 meta_456 iso_765
  5 meta_567 iso_543
  6 meta_789 iso_423
  </code></pre>
  <p>df2</p>
  <pre><code>     V1        V2       V3      V4
  1 meta_123 meta_234 meta_345 meta_456
  2 meta_123 meta_234 meta_345 meta_567
  3 meta_123 meta_345 meta_567 meta_789
  4 meta_234 meta_567 meta_456 meta_789
  etc...
  </code></pre>
  <p>I then want the following
  df3</p>
  <pre><code>     V1      V2      V3     V4
  1 iso_321 iso_987 iso_876 iso_765
  2 iso_321 iso_987 iso_876 iso_543
  3 iso_321 iso_876 iso_543 iso_423
  4 iso_987 iso_543 iso_765 iso_423
  etc...
  </code></pre>
  <p>I tried with</p>
  <pre><code>df3 &lt;- as.data.frame(ifelse(df2 %in% df1$V1, df1$V2))
  </code></pre>
  <p>But it just returns the list of df1$V2 in the same order as it is.</p>
  <p>Can anyone help me?</p>