After #3991 we are able to perform dt[, lapply(.SD, fun1), .SDcols = fun2], which is very nice.
However, if I need to assign values to the columns in the meantime, I find there's no easy way. I have to get all the colnames that match fun2 explicitly, which is quite verbose and not elegant.
For example, I have to do it like this:
vars <- names(dt)[vapply(dt, fun2, FUN.VALUE = TRUE)]
dt[, c(vars) := lapply(.SD, fun1), .SDcols = c(vars)]
But since we've already support .SDcols = fun, why not a simpler syntax for this operation?
dt[, names(.SD) := lapply(.SD, fun1), .SDcols = fun2]
I think the way of solving this is to be able to get the names of .SD in LHS.
After #3991 we are able to perform
dt[, lapply(.SD, fun1), .SDcols = fun2], which is very nice.However, if I need to assign values to the columns in the meantime, I find there's no easy way. I have to get all the colnames that match
fun2explicitly, which is quite verbose and not elegant.For example, I have to do it like this:
But since we've already support
.SDcols = fun, why not a simpler syntax for this operation?I think the way of solving this is to be able to get the names of
.SDin LHS.