The following warning occurs in both versions 1.6.6 and 1.7.1. I haven't tried other versions.<div><br></div><div><div>> DT <- data.table(var1=rep(c(1, 2), each=5),</div><div>+ var2=seq(0, 1, length.out=10),</div>
<div>+ key="var1")</div><div>> DT.2 <- DT[, list(sum(var2)), list(ifelse(var1 == 1, 1, NA))]</div><div>> setkey(DT.2, var1)</div><div>Warning message:</div><div>In setkey(DT.2, var1) :</div>
<div> Already keyed by this key but had invalid row order, key rebuilt. If you didn't go under the hood please let maintainer('data.table') know so the root cause can be fixed.</div></div><div><br></div>