I have data.table like this:
x <- data.table( a = c( 1, 2), b = c(\'foo\', \'bar\'))
I want to add a new column \
You can use do.call(), using .SDcols to supply the columns.
do.call()
.SDcols
x[, key_ := do.call(paste, c(.SD, sep = "_")), .SDcols = names(x)]
.SDcols = names(x) supplies all the columns of x. You can supply any vector of names or column numbers there.
.SDcols = names(x)
x