title: Non-equi join using data.table: column missing from the output
body: <p>I am doing a left non-equi join using <code>data.table</code>:</p>
  
  <pre><code>OUTPUT &lt;- DT2[DT1, on=.(DOB, FORENAME, SURNAME, POSTCODE, START_DATE &lt;= MONTH, EXPIRY_DATE &gt;= MONTH)]
  </code></pre>
  
  <p>The <code>OUTPUT</code> contains a correct left join, with the exception that the <code>MONTH</code> column (which is present in DT1) is missing.</p>
  
  <p>Is this a bug in <code>data.table</code>?</p>
  
  <p>NB: Of course, <code>START_DATE</code>, <code>EXPIRY_DATE</code> and <code>MONTH</code> are in the same YYYY-MM-DD, IDate format. The results of the join are correct based on these non-equi criteria. It is just that the column is missing and I need to use it in further work.</p>
  
  <p><strong>Edit 1</strong>: Simplified reproducible example</p>
  
  <pre><code>DT1 &lt;- structure(list(ID = c(1, 2, 3), FORENAME = c("JOHN", "JACK", 
  "ROB"), SURNAME = c("JOHNSON", "JACKSON", "ROBINSON"), MONTH = structure(c(16953L, 
  16953L, 16953L), class = c("IDate", "Date"))), .Names = c("ID", 
  "FORENAME", "SURNAME", "MONTH"), row.names = c(NA, -3L), class = c("data.table", 
  "data.frame"))
  
  DT2 &lt;- structure(list(CERT_NUMBER = 999, FORENAME = "JOHN", SURNAME = "JOHNSON", 
      START_DATE = structure(16801L, class = c("IDate", "Date")), 
      EXPIRY_DATE = structure(17166L, class = c("IDate", "Date"
      ))), .Names = c("CERT_NUMBER", "FORENAME", "SURNAME", "START_DATE", 
  "EXPIRY_DATE"), row.names = c(NA, -1L), class = c("data.table", 
  "data.frame"))
  
  OUTPUT &lt;- DT2[DT1, on=.(FORENAME, SURNAME, START_DATE &lt;= MONTH, EXPIRY_DATE &gt;= MONTH)]
  
  &gt; OUTPUT
     CERT_NUMBER FORENAME  SURNAME START_DATE EXPIRY_DATE ID
  1:         999     JOHN  JOHNSON 2016-06-01  2016-06-01  1
  2:          NA     JACK  JACKSON 2016-06-01  2016-06-01  2
  3:          NA      ROB ROBINSON 2016-06-01  2016-06-01  3
  </code></pre>
  
  <ul>
  <li><code>FORENAME</code> and <code>SURNAME</code> are joined on and are present in the output.</li>
  <li><code>MONTH</code> is also (non-equi) joined on, and is absent from the output.</li>
  </ul>
  
  <p>Why is this expected behaviour?</p>
  
  <p>Even if it is expected behaviour, it is not helpful in my case, because I need to retain <code>MONTH</code> for further data manipulation.</p>
  
  <p>My expected output would be the same table, but with the <code>MONTH</code> column retained as it is in DT1. After all, what I expect from a left join is for every row and column to be retained from the left table (DT1) and for all columns and only matched rows to be added from the right table (DT2).</p>
  
  <pre><code>   CERT_NUMBER FORENAME  SURNAME START_DATE EXPIRY_DATE ID      MONTH
  1:         999     JOHN  JOHNSON 2016-01-01  2016-12-31  1 2016-06-01
  2:          NA     JACK  JACKSON       &lt;NA&gt;        &lt;NA&gt;  2 2016-06-01
  3:          NA      ROB ROBINSON       &lt;NA&gt;        &lt;NA&gt;  3 2016-06-01
  </code></pre>
  
  <p><strong>Edit 2</strong>: apparently in the output produced by my code, the START and END dates are also wrong! Only person 1 had a certificate with a start date on 1-Jan and end date on 31-Dec! The expected output is what it should be. But the actual output made everything 1-Jan.</p>