title: Replace empty / NA Values from data table with other values from the same data table in R
body: <p>I would love to replace empty/NA values from a data table with other values that are shown in the variable of the same data table</p>
  <p>So I have something like this:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">Country</th>
  <th style="text-align: center;">Nationality</th>
  <th style="text-align: right;">currentLoc</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">AR</td>
  <td style="text-align: center;">ES</td>
  <td style="text-align: right;">RU</td>
  </tr>
  <tr>
  <td style="text-align: left;">empty</td>
  <td style="text-align: center;">empty</td>
  <td style="text-align: right;">ES</td>
  </tr>
  <tr>
  <td style="text-align: left;">empty</td>
  <td style="text-align: center;">AR</td>
  <td style="text-align: right;">AR</td>
  </tr>
  <tr>
  <td style="text-align: left;">EN</td>
  <td style="text-align: center;">EN</td>
  <td style="text-align: right;">EN</td>
  </tr>
  <tr>
  <td style="text-align: left;">EN</td>
  <td style="text-align: center;">ES</td>
  <td style="text-align: right;">ES</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Result should be:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">Country</th>
  <th style="text-align: center;">Nationality</th>
  <th style="text-align: right;">currentLoc</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">AR</td>
  <td style="text-align: center;">ES</td>
  <td style="text-align: right;">RU</td>
  </tr>
  <tr>
  <td style="text-align: left;">ES</td>
  <td style="text-align: center;">empty</td>
  <td style="text-align: right;">ES</td>
  </tr>
  <tr>
  <td style="text-align: left;">AR</td>
  <td style="text-align: center;">AR</td>
  <td style="text-align: right;">EN</td>
  </tr>
  <tr>
  <td style="text-align: left;">EN</td>
  <td style="text-align: center;">EN</td>
  <td style="text-align: right;">EN</td>
  </tr>
  <tr>
  <td style="text-align: left;">EN</td>
  <td style="text-align: center;">ES</td>
  <td style="text-align: right;">ES</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I wrote the following R code:</p>
  <pre><code>df1$Country[df1$Country== &quot;&quot; | df1$Country==&quot;  &quot;] &lt;- &quot;empty&quot;
  
  df1$Country &lt;-ifelse(df1$Country == &quot;empty&quot;, df1$Nationality, ifelse(df1$Nationality == &quot;empty&quot;, df1$currentLoc, df1$Country))
  </code></pre>
  <p>However not all &quot;empty&quot; cells are replaced in the &quot;Country&quot; Column.</p>
  <p>I tried already to specify the empty spaces in the <code>df1$Country</code> with <code>NA</code>, so I have done like</p>
  <pre><code>df1$Country[df1$Country== &quot;&quot; | df1$Country==&quot;  &quot;] &lt;- NA
  
  df1$Country &lt;-ifelse(is.na(df1$Country), df1$Nationality, ifelse(is.na(df1$Nationality), df1$currentLoc, df1$Country))
  </code></pre>
  <p>That is unfortunately also not working.</p>
  <p>Could you help me out in this? I searched for similar questions here, but did not quit get the desired response.</p>
  <p>Any help very much appriciated. :)</p>
  <p>Cheers</p>
  <p>Le1nO</p>