Skip to content

[R-Forge #2396] Support "by without by" with "not joins"  #604

@arunsrinivasan

Description

@arunsrinivasan

Submitted by: Garrett See; Assigned to: Nobody; R-Forge link

When using "not joins", j is not evaluated for each row of i. This behavior is consistent with the old not-join idiom; i.e. not a new bug.

DT = data.table(x=rep(c("a","b","c"),each=3), y=c(1,3,6), v=1:9)
setkey(DT,x) 

DT[!J("a"), sum(y)]
# [1] 20
DT[!"a", sum(y)]
# [1] 20

This is no different than the old way, so it is "expected" behavior:

DT[-DT["a", which=TRUE, nomatch=0], sum(y)]
# [1] 20

But since !"a" is the same as c("b", "c"),

identical(DT[!J("a")], DT[J(c("b", "c"))]) # TRUE
# [1] TRUE

I would have expected it to be the same as joining the columns other than "a":

DT[J(c("b", "c")), sum(y)]
#    x V1
#1: b 10
#2: c 10
DT[c("b", "c"), sum(y)]
#    x V1
#1: b 10
#2: c 10

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions