title: How to replace or recode values by map()
body: <p>Here is my df(just an example of course)</p>
  <pre><code>  B73   Lo1016 LxB2  LxB3  LxB4 
  1 AA    AA     AA    AA    AA   
  2 GG    GG     GG    GG    GG   
  3 GG    GG     GG    GG    GG   
  4 GG    GG     GG    GG    GG   
  5 GG    GG     GG    GG    GG   
  6 CC    GG     CC    GG    CC   
  7 GG    AA     GG    AA    GG   
  </code></pre>
  <p>What I want to do is to recode all genotypes in df: if one value keeps the same as the couterpart in
  column B73, then it is defined as &quot;B&quot;; same as that in Lo1016, &quot;A&quot;; none of them, NA.</p>
  <p>I have finished this with two-layer &quot;for&quot; function(codes attached below), but I want to imporve by map_dfr() or map_dfc(). However I have no idea to define a function to replace or recode genotypes...Would you mind offering some advice kindly? Thank you very much!</p>
  <pre><code>for (j in 1:7) {
    for (i in 1:5) {
      if (df1[i,j] == df[i,1]){
       df1[i,j] = &quot;B&quot; 
      }
      else if (df1[i,j] == df[i,2]){
       df1[i,j] = &quot;A&quot;
      }
      else {
       df1[i,j] = &quot;NA&quot;
      }
    }
  }
  </code></pre>