Skip to content

[R-Forge #1746] Passing logical column to "i" doesn't work. #243

@arunsrinivasan

Description

@arunsrinivasan

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions