Skip to content

Consistency in 'i' for integer and logical types #697

@arunsrinivasan

Description

@arunsrinivasan

Currently, there is one small inconsistency in row-subset using integer and logical types:

require(data.table)
DT <- data.table(x=1:2, y=c(TRUE, FALSE))
v1 = 1L

i as integer:

DT[1L]
#    x    y
#1: 1 TRUE
DT[x]
# Error in eval(expr, envir, enclos) : object 'x' not found 
# Corrected the output here.. Thanks to @eddi.
DT[v1]
#    x    y
#1: 1 TRUE
DT[(x)]
#    x     y
#1: 1  TRUE
#2: 2 FALSE

The same happens for logical type as well.

The question is, can we get this indexing to work without the need for ( for cases where i is a column in DT instead of throwing the error?

Edit: Cleaned up noise and retained just the resolution.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions