Joining Data with data.table in R
Scott Ritchie
Postdoctoral Researcher in Systems Genomics
Add information from the right data.table
to the left data.table
merge(x = demographics, y = shipping, by = "name", all.x = TRUE)
Add information from the left data.table
to the right 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)
Default values for all
, all.x
and all.y
are FALSE
in the merge()
function
Look up function argument defaults using help("merge")
Left join shipping
to demographics
:
merge(demographics, shipping, by = "name", all.x = TRUE)
Right join shipping
to demographics
:
merge(demographics, shipping, by = "name", all.y = TRUE)
Joining Data with data.table in R