<div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">I recently updated from data.table 1.7.1 to 1.8.2 and found that my old code using data.table</div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
no longer works. I'm not sure if this is being caused by a bug in the new version of data.table</div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">or an intentional change to the way data.table works.</div>
<div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
In 1.7.1, I could do the following:</div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><div><font face="courier new, monospace">> DT <- data.table(x=rep(c("a","b","c"),each=3), y=c(1,3,6), v=1:9)</font></div>
<div><font face="courier new, monospace">> setkey(DT, x)</font></div><div><font face="courier new, monospace">> DT[J(c("a", "b", "d")), sum(v), by=x]</font></div><div><font face="courier new, monospace"> x V1</font></div>
<div><font face="courier new, monospace">[1,] a 6</font></div><div><font face="courier new, monospace">[2,] b 15</font></div><div><font face="courier new, monospace">[3,] <NA> NA</font></div></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<br></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
In 1.8.2, however, I get an error message:</div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><div><font face="courier new, monospace">> DT <- data.table(x=rep(c("a","b","c"),each=3), y=c(1,3,6), v=1:9)</font></div>
<div><font face="courier new, monospace">> setkey(DT, x)</font></div><div><font face="courier new, monospace">> DT[J(c("a", "b", "d")), sum(v), by=x]</font></div><div><font face="courier new, monospace">Error in if (any(irows < 1L | irows > nrow(x))) stop("Internal error: some irows<1 or >nrow(x)") : </font></div>
<div><font face="courier new, monospace"> missing value where TRUE/FALSE needed</font></div></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<br></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">Looking through the NEWS file I don't see any mention of this change (It's possible that I just missed it).</div>
<div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">If this an intentional change, I would ask that you consider reverting it. It seems inconsistent that</div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<font face="courier new, monospace">DT[J(c("a", "b", "d"))]</font><font face="arial, helvetica, sans-serif"> adds a new row to the table, but </font><font face="courier new, monospace">DT[J(c("a", "b", "d")), sum(v), by=x]</font></div>
<div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><font face="arial, helvetica, sans-serif">causes </font><span style="font-family:arial,helvetica,sans-serif">an error.</span></div>
<div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
Personally I think the following makes the most sense. <span style="font-family:arial,helvetica,sans-serif">But just reverting back to what it did in 1.7.1</span></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<span style="font-family:arial,helvetica,sans-serif">seems </span><span style="font-family:arial,helvetica,sans-serif">better than having an error.</span></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<font face="courier new, monospace">> DT[J(c("a", "b", "d")), sum(v), by=x]</font></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<font face="courier new, monospace"> x V1</font></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><font face="courier new, monospace">[1,] a 6</font></div>
<div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><font face="courier new, monospace">[2,] b 15</font></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<font face="courier new, monospace">[3,] d NA</font></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<br></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">Thank you,</div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
Mike</div>