title: R: How to replace values in one column using a replacement table
body: <p>My dataframe looks something like <code>df</code>, and I would like to replace the values in X1 using a conversion table <code>replacement_table</code>. If values in X1 match the values in <code>replacement_table$coordinates</code>, then that value would be replaced with the corresponding value in <code>replacement_table$location</code></p>
  <pre><code>replacement_table &lt;- data.frame (location = c(&quot;locationA&quot;, &quot;locationB&quot;, &quot;locationC&quot;),
                                   coordinates = c(&quot;42.8+-70.89&quot;, &quot;42.85+-72.21&quot;, &quot;31.28+-72.14&quot;))
  
  
  df &lt;- data.frame(X1 = c(&quot;42.8+-70.89&quot;, &quot;42.8+-70.89&quot;, &quot;31.28+-72.14&quot;, &quot;31.28+-72.14&quot;, &quot;42.85+-72.21&quot;),
                   X2 = c(&quot;23.2+-81.32&quot;, &quot;42.8+-70.89&quot;, &quot;31.28+-72.14&quot;, &quot;23.2+-81.32&quot;, &quot;42.8+-70.89&quot;), 
                   X3 = c(&quot;19371&quot;, &quot;0&quot;, &quot;0&quot;, &quot;19278&quot;, &quot;28912&quot;))
  </code></pre>
  <p>The output would look something like this:</p>
  <pre><code>df &lt;- data.frame(X1 = c(&quot;locationA&quot;, &quot;locationA&quot;, &quot;locationC&quot;, &quot;locationC&quot;, &quot;locationB&quot;),
                   X2 = c(&quot;23.2+-81.32&quot;, &quot;42.8+-70.89&quot;, &quot;31.28+-72.14&quot;, &quot;23.2+-81.32&quot;, &quot;42.8+-70.89&quot;), 
                   X3 = c(&quot;19371&quot;, &quot;0&quot;, &quot;0&quot;, &quot;19278&quot;, &quot;28912&quot;))
  </code></pre>