left join :左连接,返回左表中所有的记录以及右表中连接字段相等的记录。
right join :右连接,返回右表中所有的记录以及左表中连接字段相等的记录。
SQL语句
inner join: 内连接,又叫等值连接,只返回两个表中连接字段相等的行。
full join:外连接,返回两个表中的行:left join + right join
cross join:结果是笛卡尔积,就是第一个表的行数乘以第二个表的行数。
dplyr包包含了各种关联查询的函数,如inner_join,left_join,full_join,rigth_join......library(dplyr)
library("nycflights13")
# Drop unimportant variables so it's easier to understand the join results.
flights2 <-
flights %>%
select(year:day,tailnum, carrier)
flights2 %>%
left_join(airlines,by= "carrier")