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

Respect nomatch = 0L for integer i #3109

Closed
mllg opened this issue Oct 15, 2018 · 3 comments · Fixed by #4353
Closed

Respect nomatch = 0L for integer i #3109

mllg opened this issue Oct 15, 2018 · 3 comments · Fixed by #4353
Assignees
Milestone

Comments

@mllg
Copy link
Contributor

mllg commented Oct 15, 2018

Currently nomatch seems to be ignored if i in dt[i, j, nomatch = 0L] is integer. Values of i which are out of bounds or NA result in rows filled with NA:

dt = data.table(x = 1:10)
dt[c(1L, 11L, NA_integer_), x, nomatch = 0L]
> 1 NA NA

I see no reason to not support nomatch = 0L for integer i.

Also note that the current handling of negative integer i seems to be inconsistent with not-joins:

# mixing negation/not-join with nomatch
dt[-1L, nomatch = 0L] # works, nomatch ignored
dt[!list(1L), on = "x", nomatch = 0L] # exception

# negation/not-join with out-of-bounds values
dt[-11L] # warning
dt[!list(11), on = "x"] # no warning
@franknarf1
Copy link
Contributor

For the second part, the inconsistent behavior is good, right?

I generally don't want a warning when part of an anti-join matches nothing, but do want it when I pass a row number outside of range. There are other safeguards on row numbers that don't have join analogies too (eg, dt[c(-1,1)] errors).

@mllg
Copy link
Contributor Author

mllg commented Oct 15, 2018

I generally don't want a warning when part of an anti-join matches nothing, but do want it when I pass a row number outside of range.

Well, I'm not sure about it. Base R also does not give a warning:

x = 1:10
x[-11L] # no warning, works fine
x[c(-1L,1L)] # also an exception

@jangorecki
Copy link
Member

please use nomatch=NULL from now on

@jangorecki jangorecki changed the title [Request] Respect nomatch = 0L for integer i Respect nomatch = 0L for integer i Apr 3, 2020
jangorecki added a commit that referenced this issue Apr 4, 2020
@jangorecki jangorecki self-assigned this Apr 5, 2020
@mattdowle mattdowle added this to the 1.14.1 milestone Aug 21, 2021
@jangorecki jangorecki modified the milestones: 1.14.9, 1.15.0 Oct 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants