title: Replacing a variable name in data1 with the value of Column2 in Data2 when the variable name in Data1 is identical to the value of Column1 in Data2
body: <p>I am a R beginner. I have two datasets like </p>
  
  <pre><code>df1 &lt;- t(data.frame(seq(1,6,by=1),seq(6,1,by=-1)))    
  colnames(df1) &lt;- c("ZZZ","YYY","CCC","DDD","XXX","KKK")    
  rownames(df1) &lt;- c("a","b")    
  Vector1&lt;-c("AAA", "BBB", "CCC", "DDD", "EEE", "FFF")
  Vector2&lt;-c("a", "b", "e", "f", "k", "l")
  df2&lt;-data.frame(cbind(Vector1, Vector2))
  </code></pre>
  
  <p>df1 is </p>
  
  <pre><code>   ZZZ  YYY  CCC  DDD  XXX  KKK
  a    1    2    3    4    5    6
  b    6    5    4    3    2    1
  </code></pre>
  
  <p>df2 is </p>
  
  <pre><code>    Vector1  Vector2
   1  AAA      a
   2  BBB      b
   3  CCC      e
   4  DDD      f
   5  EEE      k
   6  FFF      l
  </code></pre>
  
  <p>I would like to replace a variable name in df1 with the value of Vector2 in df2 when the variable name in df1 is identical to the value of Vector1 in df2. </p>
  
  <p>So, ideally, I would like to get something like</p>
  
  <pre><code>     ZZZ  YYY  e    f    XXX  KKK
  a    1    2    3    4    5    6
  b    6    5    4    3    2    1
  </code></pre>
  
  <p>I have tried to modify the codes provided in <a href="https://stackoverflow.com/questions/41951418/match-row-names-and-column-names-to-values-in-another-data-frame">Match row names and column names to values in another data frame</a>. But, to me changing the name of an identified variable in df1 is somewhat challenging. Any suggestion or comment will be highly appreciated. </p>