Below is my data table:
DT = data.table(ID = c("a","b","c"), a=1:3, b=10:12, c=100:102)
ID a b c
1: a 1 10 100
2: b 2 11 101
3: c 3 12 102
I am trying to select columns a and b and renaming the selected columns to column1 and column2, respectively
DT[, .(a=column1, b=column2)]
But get the below error, not sure why. Error in eval(jsub, SDenv, parent.frame()) : object 'column1' not found
Per the documentation page for the package, I would have expected the above to work https://cran.r-project.org/web/packages/data.table/vignettes/datatable-intro.html
DT[, .(column1 = a, column2 = b)], but it will only get the columns that was in side the.()' - akrun