Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
gsee opened this issue Jan 12, 2015 · 1 comment
Closed
Assignees
Labels
Milestone

Comments

@gsee
Copy link

gsee commented Jan 12, 2015

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]
@arunsrinivasan
Copy link
Member

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

@arunsrinivasan arunsrinivasan self-assigned this Jan 12, 2015
@arunsrinivasan arunsrinivasan added this to the v1.9.6 milestone Jan 12, 2015
mattdowle added a commit that referenced this issue Sep 29, 2016
…Col==3] where DT is one row and someCol is NA, returns no rows for consistency with nrow>1 cases. +with=FALSE with := now warns. +nomatch with := now warns. +logical i no longer recycles unless length 1 or nrow. #1001 #1002 #759 #354 #166 and closes #1252.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants