Consider some sample data
library(data.table)
dt1 <- data.table(foo = 1:4, bar = letters[1:4])
dt2 <- data.table(foo1 = 2:5, bar1 = LETTERS[1:4])
I am trying to join these two sample data.tables by non-equi join (which also needs me to set cartesian join option):
options("datatable.allow.cartesian" = T)
dt3 <- dt1[dt2, on = .(foo < foo1), nomatch = 0L]
dt3
comes out to be:
foo bar bar1
1: 2 a A
2: 3 a B
3: 3 b B
4: 4 a C
5: 4 b C
6: 4 c C
7: 5 a D
8: 5 b D
9: 5 c D
10: 5 d D
However there are 2 problems with this:
- column
foo
don't have value 5 (thats an obvious bug) - column
foo1
is not present in output (which could be limiting for further conditions; if any)
In order to bypass second condition I tried:
dt2[, foo11 := foo1]
dt4 <- dt1[dt2, on = .(foo < foo1), nomatch = 0L]
options("datatable.allow.cartesian" = F)
which gives me dt4
:
foo bar bar1 foo11
1: 2 a A 2
2: 3 a B 3
3: 3 b B 3
4: 4 a C 4
5: 4 b C 4
6: 4 c C 4
7: 5 a D 5
8: 5 b D 5
9: 5 c D 5
10: 5 d D 5
So here foo11
is essentially a copy of errorneous column foo
which looks like another bug due to non-equi join.
Am I missing any point or doing something wrong here?