Let say I have below data.table
library(data.table)
DT <- data.table(x=sample(letters, 1e6, TRUE), y=rnorm(1e6), v=runif(1e6))
Now I want to subset DT
based on the 1st column value equals to letters[1:2]
If the chose column by name, then this is straighforward -
DT[x %in% letters[1:2]]
However I want to select column by placement i.e. first column or 4th column etc
Below code doesnt work
DT[1 %in% letters[1:2]]
Any pointer on what will be right syntax to select column based on placement, would be helpful