Kết hợp dữ liệu với data.table trong R
Scott Ritchie
Postdoctoral Researcher in Systems Genomics
Thêm thông tin từ data.table bên phải vào data.table bên trái
merge(x = demographics, y = shipping, by = "name", all.x = TRUE)

Thêm thông tin từ data.table bên trái vào data.table bên phải
merge(x = demographics, y = shipping, by = "name", all.y = TRUE)

# Right join
merge(x = demographics, y = shipping, by = "name", all.y = TRUE)
# Tương đương với
merge(x = shipping, y = demographics, by = "name", all.x = TRUE)
Giá trị mặc định của all, all.x và all.y là FALSE trong hàm merge()
Tra cứu giá trị mặc định của đối số bằng help("merge")
Left join shipping vào demographics:
merge(demographics, shipping, by = "name", all.x = TRUE)
Right join shipping vào demographics:
merge(demographics, shipping, by = "name", all.y = TRUE)
Kết hợp dữ liệu với data.table trong R