I have these two DTs that I'd like to perform inner join;
DT1:
x y v foo
1: A A1 1 1
2: B A1 2 1
3: C A1 3 1
4: D A2 4 1
5: E A2 5 2
6: F A2 6 1
7: G A3 7 2
8: H A3 8 0
9: I A3 9 0
DT2:
x z
1: A 1
2: B 2
3: C 3
4: D 4
5: E 5
6: F 6
Inner join of these two by DT[DT2, nomatch=0L, on="x"]
will be :
x y v foo z
1: A A1 1 1 1
3: C A1 3 1 3
4: D A2 4 1 4
5: E A2 5 2 5
6: F A2 6 1 6
What I want to generate is following:
x y v z
1: A A1 1 1
2: B A1 2 2
3: C A1 3 3
4: D A2 4 4
5: E A2 5 5
6: F A2 6 6
As you can see, I want to join two DTs selecting out the column(s) from one of the joining DT. I can do this by removing unwanted columns after joining but I am looking for the one way to do this in an one liner. Any help will be appreciated.