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)

# Right join
merge(x = demographics, y = shipping, by = "name", all.y = TRUE)
# Same as
merge(x = shipping, y = demographics, by = "name", all.x = TRUE)
在 merge() 中,all、all.x、all.y 的預設值都是 FALSE
使用 help("merge") 查詢函式參數的預設值
將 shipping 與 demographics 做 Left join:
merge(demographics, shipping, by = "name", all.x = TRUE)
將 shipping 與 demographics 做 Right join:
merge(demographics, shipping, by = "name", all.y = TRUE)
R 的 data.table 資料合併