I have two huge data tables (dt1 and dt2) that are almost identical except for 1 column. I want to join the tables by the p-1 columns, where p <- ncol(dt1). Should I setkey() to the p-1 columns and join using dt1[dt2]? If that is the case, how can I enter the arguments in setkey() since I can't put quoted string as argument.
Here is some simulated data:
dt1 <- data.table(matrix(rnorm(260), 10, 26))
setnames(dt1, letters)
dt2 <- copy(dt1)
dt2[,z:=rnorm(10)]
## Sections below won't run
setkey(dt1, get(letters[-which(letters=="z")]))
setkey(dt2, get(letters[-which(letters=="z")]))
dt1[dt2]