title: How to avoid data duplicates when using slider_index() with multiple observations per index value?
body: <p>I am using <code>slider::slider_index()</code> to set up a rolling time windows over a dataset. The idea is to apply a function to all points belonging to the time window.</p>
  <p>Here is a reproducible example to get all individuals (1 individual = 1 row of the dataframe) belonging to 2 consecutive days.</p>
  <pre class="lang-r prettyprint-override"><code># packages
  library(dplyr)
  library(lubridate)
  library(slider)
  # dummy data
  company &lt;- tibble(
    sales = c(2, 3, 1, 8, 4, 6, 2),
    index = as.Date(&quot;2019-08-29&quot;) + c(0, 0, 1, 1, 1, 5, 6),
  )
  # what I have done so far
  roll_index &lt;- slide_index(company, company$index, ~ .x, .before = lubridate::days(1))
  </code></pre>
  <p>Which gives:</p>
  <pre class="lang-r prettyprint-override"><code>&gt; roll_index
  [[1]]
  # A tibble: 2 x 2
    sales index     
    &lt;dbl&gt; &lt;date&gt;    
  1     2 2019-08-29
  2     3 2019-08-29
  
  [[2]]
  # A tibble: 2 x 2
    sales index     
    &lt;dbl&gt; &lt;date&gt;    
  1     2 2019-08-29
  2     3 2019-08-29
  
  [[3]]
  # A tibble: 5 x 2
    sales index     
    &lt;dbl&gt; &lt;date&gt;    
  1     2 2019-08-29
  2     3 2019-08-29
  3     1 2019-08-30
  4     8 2019-08-30
  5     4 2019-08-30
  
  [[4]]
  # A tibble: 5 x 2
    sales index     
    &lt;dbl&gt; &lt;date&gt;    
  1     2 2019-08-29
  2     3 2019-08-29
  3     1 2019-08-30
  4     8 2019-08-30
  5     4 2019-08-30
  
  [[5]]
  # A tibble: 5 x 2
    sales index     
    &lt;dbl&gt; &lt;date&gt;    
  1     2 2019-08-29
  2     3 2019-08-29
  3     1 2019-08-30
  4     8 2019-08-30
  5     4 2019-08-30
  
  [[6]]
  # A tibble: 1 x 2
    sales index     
    &lt;dbl&gt; &lt;date&gt;    
  1     6 2019-09-03
  
  [[7]]
  # A tibble: 2 x 2
    sales index     
    &lt;dbl&gt; &lt;date&gt;    
  1     6 2019-09-03
  2     2 2019-09-04
  </code></pre>
  <p>So far so good. The problem is that it is not exactly what I expected. As you can see, some data are duplicated: <code>roll_index[[3]]</code>, <code>roll_index[[4]]</code> and <code>roll_index[[5]]</code> are the same.
  What I understand is that <code>slider::slide_index()</code> goes one individual after the other even if multiple individuals belong to the same index value.</p>
  <p>How can I avoid this data duplicates as they tend to increase quite a lot the size of the ouput when I use my actual data?</p>