'Join in place multiple columns data.table

I need to join in place more than 20 columns using data.table and I cannot use the syntax in the following link, since, that would mean writing the names of the columns multiple times. I can provide an example in which I have to join 5 columns (in my actual data there are more than 20):-

data <- data.table(ref = 1:6, names = letters[1:6])
b <- data.table(ref = 1:6, radius = runif(6), height = rnorm(6), weight = rnorm(6), volume = rnorm(6), money = rnorm(6))

And I don't want to write the names of the columns while joining them like following:-

data[b, colnames(b)[-1] := .(i.radius, i.height, i.weight, i.volume, i.money), on = "ref"]

Is there any way to write the RHS in like a vector form.

Thanks in advance



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source