汇总实用技能管道操作 %inin% (快捷键 cmd/ctrl + shift +M)count 统计某列unique值dplyr 处理关系数据 (连接两个表格)innerr_join 取交集left_joinfull_joinsemi_join
inner_join,取交集inner_join(test1, test2, by = "x")2.左连left_joinleft_join(test1, test2, by = 'x')3.全连full_joinfull_join
全连full_joinfull_join( test1, test2, by = 'x')4.半连接 返回能够与y表匹配的x表所有记录semi_joinsemi_join(x = test1, y =
全连full_joinfull_join( test1, test2, by = 'x')4.
test2, by = "x")2.左连left_joinleft_join(test1, test2, by = 'x')left_join(test2, test1, by = 'x')3.全连full_joinfull_join
(test1, test2, by = 'x')#以test1的x列为列,取交集left_join(test2, test1, by = 'x')#以test2的x列为列,取交集4.3.全连full_joinfull_join
1,2,3,4,5,6))test2 生成test1、test2两个数据框inner_join(test1, test2, by = "x")4.2 左连 left_join以左侧的那个数据框为准4.3 全连 full_joinfull_join
left_join列表书写顺序决定了最终合成列表中列的顺序left_join(test1, test2, by = 'x')left_join(test2, test1, by = 'x')3.全连full_joinfull_join
by = "x") 2.左连left_joinleft_join(test1, test2, by = 'x')left_join(test2, test1, by = 'x') 3.全连full_joinfull_join
inner_join,取交集left_join(test1, test2, by = 'x') #左连left_joinleft_join(test2, test1, by = 'x') #左连left_joinfull_join
test2, by = "x")2、左连left_joinleft_join(test1, test2, by = 'x')left_join(test2, test1, by = 'x')3、全连full_joinfull_join
test2, by = 'x') #以test1的x为依据进行数据提取left_join(test2, test1, by = 'x') #以test2的x为依据进行数据提取结果如下:4.3全连full_joinfull_join
left_join(test1, test2, by = 'x') x z y1 red A 32 blue B 43 yellow C NA4 green D NA3.全连full_joinfull_join
test2, by = "x")② 左连left_joinleft_join(test1, test2, by = 'x')left_join(test2, test1, by = 'x')③ 全连full_joinfull_join
, test2, by = "x")#保留同时存在于两个表中的观测左连left_joinleft_join(test1, test2, by = 'x')#保留 test1 中的所有观测全连full_joinfull_join
x y z## 1 a 1 NA## 2 b 2 A## 3 c 3 NA## 4 d 4 NA## 5 e 5 B## 6 f 6 C(3)全连full_joinfull_join
能匹配上的数据left_join(test2, test1, by = 'x') # 全保留test2,合并test1能匹配上的数据# NA与的区别:前者为数字型NA,后者为字符型NA全连full_joinfull_join
test2, test1, by = 'x') x y z1 a 1 2 b 2 A3 c 3 4 d 4 5 e 5 B6 f 6 C3.全连full_joinfull_join
领取专属 10元无门槛券
手把手带您无忧上云