You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is probably a way to come up with the correct result in a less slow way (foverlaps?), but my point is that I expect the .N, by=.EACHI]$N > 0L way to work. Is it failing thanks to a bug or am I mistaken in using it here?
I had trouble making a smaller example. Drop the n parameter by a factor of 10 and you'll see that the problem disappears. Stranger, the OP noticed that if you repeatedly run the DT1[!(MATCHED), MATCHED := ... ] line, it will keep making changes over many iterations. Also, the OP said they couldn't construct an example when the on= condition only contained one inequality.
EDIT: one faster way of coming up with the correct result, thanks to SO OP:
w = DT1[DT2, on=.(RANDOM_STRING, DATE >= START_DATE, DATE <= EXPIRY_DATE), which=TRUE, nomatch=0]
DT1[, m := DT1_ID %in% w ]
The text was updated successfully, but these errors were encountered:
This was brought up on SO.
The goal is to find out if each row in DT1 has a match in DT2 in the sense of
on=.(RANDOM_STRING, DATE >= START_DATE, DATE <= EXPIRY_DATE)
:My usual approach is to do a join, counting matches with
.N
andby=.EACHI
. However, the OP found that this fails here:There is probably a way to come up with the correct result in a less slow way (foverlaps?), but my point is that I expect the
.N, by=.EACHI]$N > 0L
way to work. Is it failing thanks to a bug or am I mistaken in using it here?I had trouble making a smaller example. Drop the
n
parameter by a factor of 10 and you'll see that the problem disappears. Stranger, the OP noticed that if you repeatedly run theDT1[!(MATCHED), MATCHED := ... ]
line, it will keep making changes over many iterations. Also, the OP said they couldn't construct an example when theon=
condition only contained one inequality.EDIT: one faster way of coming up with the correct result, thanks to SO OP:
The text was updated successfully, but these errors were encountered: