I am trying to figure out an elegant way to use := assignment to replace many columns at once in a data.table by applying a shared function. A typi
:=
data.table
These should work if you want to refer to the columns by string name:
n = paste0("V", 20:100) dt[, (n) := lapply(n, function(x) {sqrt(get(x))})]
or
dt[, (n) := lapply(n, function(x) {sqrt(dt[[x]])})]