So basically I'm trying to merge three quite different datasets – three to be precise. I have tried using the merge()
function but without any success since the different samples vary, as well as column names.
Any suggestions how to tackle my problem?
CodePudding user response:
what you seek for is the JOIN
operation; but you need to specify columns to merge on in order to resolve ambiguities
require(data.table)
dt1 = data.table(col1=1:10, col2=5:14)
dt2 = data.table(col1=11:20, col22=LETTERS[1:10])
dt3 = data.table(col2=5:14, col3=101:110)
as.data.frame(merge(merge(dt1,dt2, all=TRUE), dt3, by='col2'))