title: R data.table join with inequality conditions between left and right table
body: <p>I saw the question on join with inequality conditions <a href="https://stackoverflow.com/questions/19053177/r-data-table-join-with-inequality-conditions">R data.table join with inequality conditions</a> and I ask myself, how would we proceed to join two data.tables with an inequality condition between these two? </p>
  
  <p>This is usually of great interest in time series, where we want to join one table X with another Y but the join should choose the first row in X that matches in a time frame smaller than the time of the row in Y. </p>
  
  <pre><code>dt &lt;- data.table(rep(c("A", "B", "C"), 4), 5:16)
  dt2 &lt;- data.table(rep(c("A", "B", "C"), 4), 1:12)
  cbind(dt,dt2)
      V1 V2 V1 V2
   1:  A  5  A  1
   2:  B  6  B  2
   3:  C  7  C  3
   4:  A  8  A  4
   5:  B  9  B  5
   6:  C 10  C  6
   7:  A 11  A  7
   8:  B 12  B  8
   9:  C 13  C  9
  10:  A 14  A 10
  11:  B 15  B 11
  12:  C 16  C 12
  </code></pre>
  
  <p>Now, take the rows from <code>dt</code>that match the rows from <code>dt2</code> on the variable <code>V1</code> but have <code>dt$V2</code>smaller than <code>dt2$V2</code>. </p>
  
  <p>How would you do this?  </p>