79076988

Date: 2024-10-11 06:16:31
Score: 4
Natty:
Report link

This answer here by @MichaelChirico is actually trying to explain what is going on under the hood: data.table join is hard to understand

Using:
library(data.table)
DT = data.table(x = rep(c("b", "a", "c"), each = 3),
                y = c(1, 3, 6),
                v = 1:9)
X = data.table(x = c("c", "b"),
               v = 8:7,
               foo = c(4, 2))

He says:

Note also that we are using the right table to "look up" rows of the left table. That means we go through the rows of X and see which rows of DT match.

This is where me saying we are working inside the scope of the left table comes from. This makes total sense to me, except when we don't get a match. When we don't get a match, we still get the rows from the right table in DT[X - because this is in effect DT right join X or X left join DT. So, the quote that we are using the right table to "look up" rows of the left table is incorrect?

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • User mentioned (1): @MichaelChirico
  • Self-answer (0.5):
  • Looks like a comment (1):
  • Low reputation (0.5):
Posted by: Helen