title: NA in data.table
body: <p>I have a <code>data.table</code> that contains some groups. I operate on each group and some groups return numbers, others return <code>NA</code>.  For some reason <code>data.table</code> has trouble putting everything back together.  Is this a bug or am I misunderstanding?  Here is an example:</p>
  
  <pre><code>dtb &lt;- data.table(a=1:10)
  f &lt;- function(x) {if (x==9) {return(NA)} else { return(x)}}
  dtb[,f(a),by=a]
  
  Error in `[.data.table`(dtb, , f(a), by = a) : 
    columns of j don't evaluate to consistent types for each group: result for group 9 has     column 1 type 'logical' but expecting type 'integer'
  </code></pre>
  
  <p>My understanding was that <code>NA</code> is compatible with numbers in R since clearly we can have a <code>data.table</code> that has <code>NA</code> values. I realize I can return <code>NULL</code> and that will work fine but the issue is with <code>NA</code>.</p>