【发布时间】:2015-02-28 12:33:50
【问题描述】:
我正在尝试使用 dplyr 中的 left_join 并指定合并键
该函数工作正常,但我遇到的问题是我想在函数之外设置合并键(即作为变量 client_1_key 和 client_2_key)。不幸的是,我在正确使用语法方面遇到了问题。任何帮助将不胜感激
client_1_key <- "customer_hashed"
client_2_key <- "customer_identifier"
client_merged <- left_join(client_1_file,
client_2_file,
by = c("customer_hashed" = "customer_identifier"))
示例client_1_file:
来源:本地数据框 [24 x 1]
customer_hashed
1
2
3
4
5
示例客户端 2 文件:
来源:本地数据框 [24 x 5]
customer_identifier health_insurance pet_insurance life_insurance car_insurance
1 1 Y N N Y
2 2 N N N Y
3 3 N N Y N
4 4 Y N N N
5 15 Y N Y N
【问题讨论】: