title: Compare values in two columns that are similar in R
body: <p>I have combined two data frames using a unique ID I created by concatenating two columns from each data frame (country and year). df2 has the correct %GDP that I want to use to overwrite the incorrect %GDP in df1.  However, when I imported the data from two different sources, the country names were represented differently.  I want to do a comparison of the country names to find which country names are different - United Kingdom instead of UK for example - and then overwrite the value in df1 which is the primary source.  Please note that each country name has 15 instances (e.g. UK 2000, UK 2001, etc.) as there is GDP data for 15 years.</p>
  <p>I know I can use the below code to replace individual instances, but I would have to check the data and find all instances of mismatched names myself and write code for each, which will take a lot of time as there are probably 10-15 instances of mismatched names and I need to do this with multiple data sources.</p>
  <pre><code>df1$`Country Name`[df1$`Country Name` == &quot;Iran, Islamic Rep.&quot;] &lt;- &quot;Iran (Islamic Republic of)&quot;
  </code></pre>
  <h3>df1</h3>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>UniqueID</th>
  <th>Country</th>
  <th>Year</th>
  <th>%GDP</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>United Kingdom 2000</td>
  <td>United Kingdom</td>
  <td>2000</td>
  <td>9.4</td>
  </tr>
  <tr>
  <td>Denmark 2000</td>
  <td>Denmark</td>
  <td>2000</td>
  <td>7.4</td>
  </tr>
  </tbody>
  </table>
  </div><h3>df2</h3>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>UniqueID</th>
  <th>Country</th>
  <th>Year</th>
  <th>%GDP</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>UK 2000</td>
  <td>UK</td>
  <td>2000</td>
  <td>8.4</td>
  </tr>
  <tr>
  <td>Denmark 2000</td>
  <td>Denmark</td>
  <td>2000</td>
  <td>5.3</td>
  </tr>
  </tbody>
  </table>
  </div>