How do I extract a column from a data.table as a vector by its position? Below are some code snippets I have tried:
DT<-data.table(x=c(1,2),y=c(3,4),z=c(5
DT[,get(names(DT)[colNb])]
where colNb can be an integer (the desired column number) or a variable containing the column number.