R 的 data.table 資料合併
Scott Ritchie
Postdoctoral Researcher in Systems Genomics
連接(join)概念來自資料庫查詢語言(如 SQL)。
四種標準連接:
四種皆可用 merge() 完成。
只保留同時在兩個 data.table 中都有資料的觀測值。
merge(x = demographics, y = shipping,
by.x = "name", by.y = "name")

用 by 可避免重複輸入相同的欄名。
merge(x = demographics, y = shipping,
by = "name")

保留出現在任一個 data.table 的所有觀測值。
merge(x = demographics, y = shipping,
by = "name", all = TRUE)

R 的 data.table 資料合併