title: How to merge datasets with data for each countries but merge only the first available date for that month, for all 6 months?
body: <p><strong>I have two datasets:</strong></p>
  <p><strong>First dataset has, let's say 3 rows, one for each countries:</strong></p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>country</th>
  <th>population</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>Afganistan</td>
  <td>23900</td>
  </tr>
  <tr>
  <td>India</td>
  <td>45980</td>
  </tr>
  <tr>
  <td>USA</td>
  <td>784560</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p><strong>Second dataset looks like this:</strong></p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>country</th>
  <th>date</th>
  <th>deaths</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>Afganistan</td>
  <td>02/13/2021</td>
  <td>134</td>
  </tr>
  <tr>
  <td>Afganistan</td>
  <td>02/18/2021</td>
  <td>342</td>
  </tr>
  <tr>
  <td>Afganistan</td>
  <td>02/22/2021</td>
  <td>543</td>
  </tr>
  <tr>
  <td>Afganistan</td>
  <td>03/02/2021</td>
  <td>421</td>
  </tr>
  <tr>
  <td>Afganistan</td>
  <td>03/07/2021</td>
  <td>456</td>
  </tr>
  <tr>
  <td>Afganistan</td>
  <td>03/16/2021</td>
  <td>675</td>
  </tr>
  <tr>
  <td>Afganistan</td>
  <td>03/19/2021</td>
  <td>689</td>
  </tr>
  <tr>
  <td>India</td>
  <td>02/02/2021</td>
  <td>4889</td>
  </tr>
  <tr>
  <td>India</td>
  <td>02/09/2021</td>
  <td>456</td>
  </tr>
  <tr>
  <td>India</td>
  <td>02/16/2021</td>
  <td>421</td>
  </tr>
  <tr>
  <td>India</td>
  <td>03/04/2021</td>
  <td>98900</td>
  </tr>
  <tr>
  <td>India</td>
  <td>03/17/2021</td>
  <td>83123</td>
  </tr>
  <tr>
  <td>India</td>
  <td>03/28/2021</td>
  <td>7645</td>
  </tr>
  <tr>
  <td>USA</td>
  <td>02/05/2021</td>
  <td>678</td>
  </tr>
  <tr>
  <td>USA</td>
  <td>02/13/2021</td>
  <td>6000</td>
  </tr>
  <tr>
  <td>USA</td>
  <td>02/19/2021</td>
  <td>34500</td>
  </tr>
  <tr>
  <td>USA</td>
  <td>02/21/2021</td>
  <td>13458</td>
  </tr>
  <tr>
  <td>USA</td>
  <td>03/05/2021</td>
  <td>3679</td>
  </tr>
  <tr>
  <td>USA</td>
  <td>03/21/2021</td>
  <td>6591</td>
  </tr>
  <tr>
  <td>USA</td>
  <td>03/26/2021</td>
  <td>1780</td>
  </tr>
  <tr>
  <td>USA</td>
  <td>03/29/2021</td>
  <td>2644</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Now I need to merge these two files in <strong>R</strong> in such a way that I will have two new columns - one each for Febryary and March deaths, and the value for death column in the final file will be from the first available date for that particular month. The file after merge should look like this:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>country</th>
  <th>population</th>
  <th>february_death</th>
  <th>march_death</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>Afganistan</td>
  <td>23900</td>
  <td>134</td>
  <td>421</td>
  </tr>
  <tr>
  <td>India</td>
  <td>45980</td>
  <td>4889</td>
  <td>98900</td>
  </tr>
  <tr>
  <td>USA</td>
  <td>784560</td>
  <td>678</td>
  <td>3679</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Thank you.</p>