A FAQ: What's a reproducible example (`reprex`) and how do I do one? would allow me to offer more than a guess, because I can't see all the variable names.
I don't like piping into joins for just this reason, it's not exactly clear whether the .
from the pipe is the implicit first or second argument to inner_join
When I'm debugging I also don't like overwriting the source, at least until I'm sure it's working, so
test_me <- inner_join(order_discrepancy, merge, by = [something])
So, now we're certain that order_discrepancy
is the LHE and merges
is the RHE.
The next question is whether it's possible to fool by
into using losingid
as the key field by sending it an alias with the name shopper_id
, and without the reprex
it's too much effort to gin up a data set to try.
You can always
test_me_2 <- order_discrepancy %>% mutate(shopper_id = losingid)
and then
result <- inner_joint(test_me, test_me2, by = "shopper_id")
if it turns out that your alias construct doesn't work.