Answers:
更新以使用tibble()
您可以将长度大于1的命名向量传递给by
参数left_join()
:
library(dplyr)
d1 <- tibble(
x = letters[1:3],
y = LETTERS[1:3],
a = rnorm(3)
)
d2 <- tibble(
x2 = letters[3:1],
y2 = LETTERS[3:1],
b = rnorm(3)
)
left_join(d1, d2, by = c("x" = "x2", "y" = "y2"))
=
:left_join(d1, d2, by = c("firstname", "lastname"))
left_join(d1, d2, by = c("firstname" = "firstname", "lastname" = "lastname"))
。对某些人可能并不明显。