"nomatch is ignored with :=" warning is misleading
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 42/100
Research direction
Start by reproducing the supplied [.data.table examples with nomatch=0 and :=, then trace where the warning is emitted. Update the warning so it reflects the demonstrated effect of nomatch, and add or adjust coverage for both examples to verify the resulting rows and warning behavior.
Written by the indexing model from the issue text.
Description
Starting in v1.9.8 this warning appears when using := with nomatch=0:
nomatch isn't relevant together with :=, ignoring nomatch
However, when I removed all the nomatch=0 from := calls in my code it caused me some issues. So I thought it was worth pointing out that the warning is not strictly true (nomatch might still be relevant in := calls; nomatch is not ignored). An illustrative example run on v1.10.4:
DT<-data.table(x=2:5)
X<-data.table(x=1:4)
DT[X, on='x', y:={ print(length(x)) ; x }]
# [1] 4
DT[X, on='x', y:={ print(length(x)) ; x }, nomatch=0]
# [1] 3
# Warning message:
# In `[.data.table`(DT, X, on = "x", `:=`(y, { :
# nomatch isn't relevant together with :=, ignoring nomatch
Above, the resulting data.table is the same, but nomatch controls whether the elimination of unmatched rows occurs in j or only on assignment. This can be relevant: it caused problems in my code when I used vectors in j that weren't in either data.table (x or i). For example:
DT[X, on='x', y:=1:3 + x, nomatch=0][]
# assume this is desired behavior
# x y
# 1: 2 3
# 2: 3 5
# 3: 4 7
# 4: 5 NA
# Warning message:
# In `[.data.table`(X, DT, on = "x", `:=`(y, 1:3 + x), nomatch = 0) :
# nomatch isn't relevant together with :=, ignoring nomatch
DT[X, on='x', y:=1:3 + x][]
# results are incorrect without nomatch=0
# x y
# 1: 2 4
# 2: 3 6
# 3: 4 5
# 4: 5 NA
# Warning message:
# In 1:3 + x :
# longer object length is not a multiple of shorter object length
Thus there remains a use case for using nomatch=0 with :=, and I don't think users should be told that it is not relevant (and definitely shouldn't be told that it is ignored). Could lead to hard-to-find problems if people assume, like I did, that there are no possible repercussions to removing nomatch=0 where := appears in their code.
- Dominant language
- R
- Stars
- 3.9k
- Forks
- 1.1k
- Avg merge
- 14h 4m
- Merged PRs (30d)
- 4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Rdatatable/data.table
-
as.data.table() recurses without end on a survival::Surv object (or any data.frame carrying one) Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Rdatatable/data.table#7887 ·
-
consistency tests
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Rdatatable/data.table#7853 · 3 comments ·
-
internals
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Rdatatable/data.table#6938 · 1 comment ·
-
encoding fread
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Rdatatable/data.table#5179 · 8 comments ·
-
documentation programming
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Rdatatable/data.table#3199 · 3 comments ·
All issues in Rdatatable/data.table
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
r-lib/pkgdepends#485 · 3 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
beginners blocker
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enviPathR OpenBuild Error Build OK Build Warning policies-accepted pre-review precheck-passed
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Bioconductor/BiocContributions#207 · 6 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
datacarpentry/semester-biology#1255 ·