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

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

Closed
arunsrinivasan opened this issue Jun 8, 2014 · 0 comments
Closed

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

arunsrinivasan opened this issue Jun 8, 2014 · 0 comments

Comments

@arunsrinivasan
Copy link
Member

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant