title: Matching two date fields using dplyr
body: <p>So I have a dataframe as such:</p>
  <pre><code>ID   key  date1
  001   02  2018-02-16
  001   02  2018-02-19
  001   03  2018-02-17
  001   03  2018-02-22
  001   04  2017-01-01
  002   11  2019-12-21
  002   12  2019-12-21
  002   13  2019-12-22
  </code></pre>
  <p>And another dataframe (DF2)</p>
  <pre><code>ID   key  date2
  001   02  2018-02-20
  001   03  2018-03-22
  002   13  2019-12-22
  002   13  2019-12-21
  </code></pre>
  <p>So the task is conceptually straightforward:</p>
  <p><strong>I would like to find the previous date that exists in DF1 to each date in DF2.</strong></p>
  <p>What do I mean by that? In DF2 for example, we see a date of <code>2018-02-20</code> as well as a corresponding Key and ID. So I go to DF1 and find the matching ID and Key, this gives me two possibilities. I need the one that's the previous, so not after. Thus it would be <code>2018-02-19</code>. I will eventually calcuate the number of days.</p>
  <p>The final df should look like this:</p>
  <pre><code>ID   key  date2           date1   day_diff
  001   02  2018-02-20 2018-02-19          1
  001   03  2018-03-22 2018-02-22         28
  002   13  2019-12-22 2019-12-22          0
  002   13  2019-12-21         NA         NA
  </code></pre>
  <p>Again, we just need the date previous to the one that is in each row of DF2. This also needs to return NA if there is no previous date.</p>