title: Rolling join on data.table with duplicate keys
body: <p>I'm trying to understand <code>rolling joins</code> in <code>data.table</code>. The data to reproduce this is given at the end.</p>
  
  <p>Given a data.table of transactions at an airport, at a given time:</p>
  
  <pre><code>&gt; dt
     t_id airport thisTime
  1:    1       a      5.1
  2:    3       a      5.1
  3:    2       a      6.2  
  </code></pre>
  
  <p>(note <code>t_ids</code> 1 &amp; 3 have the same airport and time)</p>
  
  <p>and a lookup table of flights departing from airports:</p>
  
  <pre><code>&gt; dt_lookup
     f_id airport thisTime
  1:    1       a        6
  2:    2       a        6
  3:    1       b        7
  4:    1       c        8
  5:    2       d        7
  6:    1       d        9
  7:    2       e        8
  
  &gt; tables()
       NAME      NROW NCOL MB COLS                  KEY             
  [1,] dt           3    3  1 t_id,airport,thisTime airport,thisTime
  [2,] dt_lookup    7    3  1 f_id,airport,thisTime airport,thisTime
  </code></pre>
  
  <p>I would like to match all the transactions to all the next possible flights departing from that airport, to give:</p>
  
  <pre><code>   t_id airport thisTime f_id
        1       a        6    1
        1       a        6    2
        3       a        6    1
        3       a        6    2
  </code></pre>
  
  <p>So I thought this would work:</p>
  
  <pre><code>&gt; dt[dt_lookup, nomatch=0,roll=Inf]
     t_id airport thisTime f_id
  1:    3       a        6    1
  2:    3       a        6    2
  </code></pre>
  
  <p>But it hasn't returned transactions <code>t_id == 1</code>.</p>
  
  <p>From <a href="https://cran.r-project.org/web/packages/data.table/data.table.pdf" rel="noreferrer">the documentation</a> it says:</p>
  
  <blockquote>
    <p>Usually, there should be no duplicates in x’s key,...</p>
  </blockquote>
  
  <p>However, I do have duplicates in my 'x key' (namely <code>airport</code> &amp; <code>thisTime</code>), and can't quite see/understand what's going on to mean <code>t_id = 1</code> gets removed from the output. </p>
  
  <p>Can anyone shed some light as to why <code>t_id = 1</code> is not returned, and how can I get the join to work for when I have duplicates?</p>
  
  <p><strong>Data</strong></p>
  
  <pre><code>library(data.table)
  dt &lt;- data.table(t_id = seq(1:3),
                   airport = c("a","a","a"),
                   thisTime = c(5.1,6.2, 5.1), key=c( "airport","thisTime"))
  
  dt_lookup &lt;- data.table(f_id = c(rep(1,4),rep(2,3)),
                          airport = c("a","b","c","d",
                                   "a","d","e"),
                          thisTime = c(6,7,8,9,
                                   6,7,8), key=c("airport","thisTime"))
  </code></pre>