Does anyone know how to deal with more than 2 conditions using %in%
in dplyr
like as in this exapmle?
Asked
Active
Viewed 169 times
0
-
3What did you try that didn't work? – hrbrmstr Sep 15 '15 at 12:50
-
Hi. Please [use text, not images/links, for text (including code, tables & ERDs)](https://meta.stackoverflow.com/q/285551/3404097). Use an image only for convenience to supplement text and/or for what cannot be given in text. And never give a diagram without a legend/key. Use edit functions to inline, not link, if you have the rep--make your post self-contained. Also: Please read & act on [mcve]. – philipxy Sep 20 '18 at 15:25
1 Answers
3
inner_join
(and the other joins) support arbitrarily many columns to join by.
For instance:
inner_join(a, b, by = c('x', 'y', 'z'))
Or, if the column names differ:
inner_join(a, b, by = c(x1 = 'x2', y1 = 'y2', z1 = 'z2'))

Konrad Rudolph
- 530,221
- 131
- 937
- 1,214