Operator == inconsistent in logical columns in data.table

Now fixed in v1.9.5 on GitHub.

:= and set* now drop secondary keys (new in v1.9.4) so that DT[x==y] works again after a := or set* without needing options(datatable.auto.index=FALSE). Only setkey() was dropping secondary keys correctly. 23 tests added. Thanks to user36312 for reporting, #885.


Have a look at what @nrussell suggested. This also could be a bug, according to @Eddi. Below could be a temporary work-around. Also suggested by @Arun. Please refer to the exchange of comments.

Case 1

> set.seed(123)
> DT <- data.table(A=rep(0.3,10000))
> DT[, B := runif(.N) < A]
> DT[B == T, .N]
[1] 3012
> DT[, summary(B)]
   Mode   FALSE    TRUE    NA's 
logical    6988    3012       0 

Case 2

> set.seed(123)
> DT[, B := runif(.N) < A]
> DT[B == T, .N]
[1] 3012
> DT[, summary(B)]
   Mode   FALSE    TRUE    NA's 
logical    6988    3012       0 

Case 3

> set.seed(123)
> DT[, B := runif(.N) < A]
> DT[B != F, .N]
[1] 3012
> DT[, summary(B)]
   Mode   FALSE    TRUE    NA's 
logical    6988    3012       0