Skip to content

Behaviour when j has undefined columns and i-operation leads to 0-length. #1002

Closed

Description

@arunsrinivasan

Following #1001

require(data.table) ## 1.9.5
DT = data.table(a=1:2)
options(datatable.auto.index=FALSE)
DT[a==3, b := d+1L] # no error
#    a
#1: 1
#2: 2
setkey(DT, a)
DT[J(3), b := d+1L, nomatch=0L] # error
# Error in eval(expr, envir, enclos) : object 'd' not found

I'm not convinced if the behaviour on subset is right.

Activity

  1. gsee commented on Jan 12, 2015

    @gsee

    Here is something a little closer to the actual usecase. I don't think either should be an error, but if the second one is, then the first one should be too, IMO

    DT[J(3), b := 1L, nomatch=0L] # no error
    DT[J(3), d:=b + 2, nomatch=0L] # error
    #Error in eval(expr, envir, enclos) : object 'b' not found
    
  2. arunsrinivasan commented on Jan 12, 2015

    @arunsrinivasan
    MemberAuthor

    No error makes more sense to me too (also, consistency with subset behaviour is better - as subsets and joins are very related under [).

  3. arunsrinivasan commented on Nov 8, 2015

    @arunsrinivasan
    MemberAuthor

    Seems to have been fixed in v1.9.6...

  4. added this to the v1.9.8 milestone on Nov 8, 2015
  5. arunsrinivasan commented on Mar 9, 2016

    @arunsrinivasan
    MemberAuthor

    When nomatch=NA, both expressions return an error (as expected). And otherwise, there's no rows to evaluate on. So j-exp is not looked at all = no error (as expected).

    The error on NA is very likely due to #759 fix.

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