How does one do a full join using data.table? How does one do a full join using data.table? r r

How does one do a full join using data.table?


You actually have it right there. Use merge.data.table which is exactly what you are doing when you call

merge(a, b, by = "dog", all = TRUE)

since a is a data.table, merge(a, b, ...) calls merge.data.table(a, b, ...)


x= data.table(a=1:5,b=11:15)y= data.table(a=c(1:4,6),c=c(101:104,106))setkey(x,a)setkey(y,a)unique_keys <- unique(c(x[,a], y[,a]))y[x[.(unique_keys), on="a"]  ] # Full Outer Join