I have a syntax question because I do not understand the behaveior of data.table for my problem. Similiar to this question I want to paste two columns directly together using a predefined character vector. I do not want to create a new column. MWE:
dt <- data.table(L=1:5,A=letters[7:11],B=letters[12:16])
cols<-c("A", "B")
I can paste directly using the col names without brackets as from the other question
dt[,paste0(A,B)]
But i cant using with=F or .SD
dt[,paste0(cols),with=F]
dt[,paste0(.SD),.SDcols=cols]
Why do I have to use a do.call?
dt[,do.call(paste0,.SD), .SDcols=cols]