Skip to content

Right-hand side of := assignment should not be evaluated when auto.index=TRUE #1001

Closed

Description

@gsee

If auto.index is TRUE, the RHS of := is evaluated even if there are zero rows in the subset.

packageVersion('data.table')
#[1] ‘1.9.5’
options(datatable.auto.index=TRUE)
DT <- data.table(a=1:2)
DT[a==3, b:=d+1]
# Error in eval(expr, envir, enclos) : object 'd' not found

Since DT[a==3] above returns a zero row data.table, there is nothing to assign in the j expression, so it should not be evaluated. This did not throw an exception in 1.9.3 and does not throw an exception if auto.index is turned off.

options(datatable.auto.index=FALSE)
DT[a==3, b:=d+1]

Activity

  1. arunsrinivasan commented on Jan 12, 2015

    @arunsrinivasan
    Member

    I've restored old behaviour for subset operations. But I'm not sure if it shouldn't error. Opened #1002.

  2. added this to the v1.9.6 milestone on Jan 12, 2015
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