Submitted by: Leon Baum; Assigned to: Nobody; R-Forge link
DT <- data.table(x = sample(c(TRUE, FALSE), size = 10, replace = TRUE), y = rnorm(10))
DT[x, ]
Error in eval(expr, envir, enclos) : object 'x' not found
sapply(DT, class)
x y
"logical" "numeric"
DT[as.logical(x), ]
x y
[1,] TRUE -0.5545989
[2,] TRUE 1.1293858
[3,] TRUE 0.4526295
As you can see above, even though column "x" is of type logical, it still requires a cast, which shouldn't be needed.
Submitted by: Leon Baum; Assigned to: Nobody; R-Forge link
As you can see above, even though column "x" is of type logical, it still requires a cast, which shouldn't be needed.