I have two data.tables:
require(data.table)
set.seed(11)
dt = data.table(a=c(1,2,3,2,1,3,2,3,2,1,2,3))
V = c(1/2,1/8,3/2)
names(V) = c('1','2','3')
I'd like to bind these two data.tables so that for each value in dt1$a corresponds (=stands on the same row) the value of V which name equals the value in dt1$a. At the end, the newly constructed data.table should have ncol(dt1)+1 columns and nrow(dt1) rows. For example: As in row 6, a 3 appears in dt1$a, the value of V, named 3 should appears in row 6 of the newly created data.table.
Hope this makes sense. I expect this operation to be basic, it is just hard to me to explain it with simple words!