Sitelet https://github.com/Rdatatable/data.table/issues/1985
Skip to content

weird exception when by contains get #1985

Description

@valentas-kurauskas

Just copied my question on stackoverflow:

get function usually works without problems in data.table, but I am not able to understand the reason of this bug.

library(data.table)
tb<-data.table(x=c(1,2), y=c(3,4), z=c(5,6), w=c("a","b"))
tb[w != "b", .(x=sum(x)), by=.(y, zz=z)] #OK
#    y zz x
# 1: 3  5 1
tb[, .(x=sum(x)), by=.(y, zz=get("z"))] #OK
#    y zz x
# 1: 3  5 1
# 2: 4  6 2
tb[w != "b", .(x=sum(x)), by=.(y, zz=get("z"))] #not OK?!

Error in get("z") : object 'z' not found

(I use R version 3.3.2 and data.table version 1.9.6.)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    programmingparameterizing queries: get, mget, eval, env

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions