dt_keep_cols {libbib} | R Documentation |
Takes a data.table and a quoted sequence of column names and removes all columns but the ones specified
dt_keep_cols(DT, ...)
DT |
A data.table |
... |
arbitrary number of column names in quotes |
Returns data.table with only those columns
mt <- as.data.table(mtcars)
dt_keep_cols(mt, "mpg", "am", "gear", "carb")