Operator == inconsistent in logical columns in data.table
Now fixed in v1.9.5 on GitHub.
:=
andset*
now drop secondary keys (new in v1.9.4) so thatDT[x==y]
works again after a:=
orset*
without needingoptions(datatable.auto.index=FALSE)
. Onlysetkey()
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