title: Tally if observations fall in date windows
body: <p>I have a data frame that represents policies with start and end dates.  I'm trying to tally the count of policies that are active each month.</p>
  <pre><code>library(tidyverse)
  
  ayear &lt;- 2021
  amonth &lt;- 10
  months &lt;- 12
  
  df &lt;- tibble(
    pol = c(1, 2, 3, 4)
    , bdate = c('2021-02-23', '2019-12-03', '2020-08-11', '2020-12-14')
    , edate = c('2022-02-23', '2020-12-03', '2021-08-11', '2021-06-14')
    )
  </code></pre>
  <p>These four policies have a begin date (<em>bdate</em>) and end date (<em>edate</em>).  Beginning in October (<em>amonth</em>) 2021 (<em>ayear</em>) and going back 12 months (<em>months</em>) I'm trying to generate a count of how many of the 4 policies were active at some point in the month to generate a data frame that looks something like this.</p>
  <p>Data frame I'm trying to generate would have three columns: month, year, and active_pol_count with 12 rows.  Like this.</p>
  <p><a href="https://i.stack.imgur.com/Dz9nI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Dz9nI.png" alt="desired output" /></a></p>