การ Join ข้อมูลด้วย data.table ใน R
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)
ค่าดีฟอลต์ของ all, all.x และ all.y คือ FALSE ในฟังก์ชัน merge()
ดูค่าดีฟอลต์ของอาร์กิวเมนต์ได้ด้วย help("merge")
Left join shipping กับ demographics:
merge(demographics, shipping, by = "name", all.x = TRUE)
Right join shipping กับ demographics:
merge(demographics, shipping, by = "name", all.y = TRUE)
การ Join ข้อมูลด้วย data.table ใน R