Select mutilple columns in data.table
dt
is a data.table with multiple columns (variables), if we want to select many columns in one go, we could do this:dt[, columnA:columnD]
.
Also, we could delete multiple columns with -
or !
:dt[, -(columnA:columnD)]
, dt[, !(columnA:columnD)
, note that the column names should be in brackets ()
.