title: Why I use 'on' in data.table can make "NA"
body: <p>First,I make a data.table.</p>
  
  <pre><code>    set.seed(100)
      a &lt;- data.table(x = sample(c(1:1000),100000,replace = TRUE),
                  y = sample(letters,100000,replace = TRUE),
                  z = 1:100000)
  </code></pre>
  
  <p>I use one method <code>a[x &gt;= 900 &amp; y == 'b', .N]</code>,then the result is 389.</p>
  
  <p>Then I use another method <code>a[.(c(900:max(x)),'b'), .N, on = .(x,y)]</code>,the result is 394.</p>
  
  <p>I find that the second method can make 'NA'</p>
  
  <p><code>a[.(c(900:max(x)),'b'), on = .(x,y)][is.na(z)]</code></p>
  
  <p>WHY??</p>