I have the following data.table:
dt<- data.table(V1=c(1L,2L),
V2=LETTERS[1:3],
V3=1:12)
I want to subset the first and second columns like this:
dt2 <- dt[, c("V1", "V2")]
Works fine. However, when trying...
chosen.cols <- c("V1", "V2")
dt[,(chosen.cols),with = F]
... it only works appending the 'with=F'
, otherwise it returns:
[1] "V1" "V2"
1) Why do we need 'with ='
?
2) What exactly 'with ='
implies to the code?
Thank you.