在 R 中使用 data.table 进行数据表连接
Scott Ritchie
Postdoctoral Researcher in Systems Genomics
将右侧 data.table 的信息添加到左侧 data.table
merge(x = demographics, y = shipping, by = "name", all.x = TRUE)

将左侧 data.table 的信息添加到右侧 data.table
merge(x = demographics, y = shipping, by = "name", all.y = TRUE)

# 右连接
merge(x = demographics, y = shipping, by = "name", all.y = TRUE)
# 等同于
merge(x = shipping, y = demographics, by = "name", all.x = TRUE)
在 merge() 中,all、all.x、all.y 的默认值均为 FALSE
可用 help("merge") 查看参数默认值
将 shipping 左连接到 demographics:
merge(demographics, shipping, by = "name", all.x = TRUE)
将 shipping 右连接到 demographics:
merge(demographics, shipping, by = "name", all.y = TRUE)
在 R 中使用 data.table 进行数据表连接