[datatable-help] Problem with keys when by= generates NAs

Muhammad Waliji mhwaliji at google.com
Fri Oct 21 21:49:18 CEST 2011


The following warning occurs in both versions 1.6.6 and 1.7.1.  I haven't
tried other versions.

> DT <- data.table(var1=rep(c(1, 2), each=5),
+                  var2=seq(0, 1, length.out=10),
+                  key="var1")
> DT.2 <- DT[, list(sum(var2)), list(ifelse(var1 == 1, 1, NA))]
> setkey(DT.2, var1)
Warning message:
In setkey(DT.2, var1) :
  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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20111021/21a4f826/attachment.htm>


More information about the datatable-help mailing list