Skip to content

mget doesn't find columns (without specifying the environment explicitly) #994

Closed

Description

@ecoRoland
DT <- data.table(a=1:2, b=c("x", "y")) 
DT[, get("a")] 
#[1] 1 2 
DT[, mget("a", inherits = TRUE)] 
#Error: value for ‘a’ not found

It works if the correct environment is specified:

DT[, mget("a", as.environment(.SD))] 
#   a
#1: 1
#2: 2

According to Arun:

The j-exp is parsed and checked for get(), but not mget(). Therefore the SD environment isn't constructed with the required columns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions