Reorder columns of a data.table (via setcolorder) so that particular columns
appear first (or last), or in a particular order.
Usage
set_cols_first(DT, cols, intersection = TRUE)
set_cols_last(DT, cols, intersection = TRUE)
set_colsuborder(DT, cols, intersection = TRUE)
Arguments
DT
A data.table.
cols
Character vector of columns to put before (after) all others or, in the case of set_colsuborder,
a vector of columns in the order requested.
intersection
Use the intersection of the names of DT and cols. If FALSE
any cols are not the names of DT, the function may error on behalf of data.table.
Not available for set_colsuborder.
Details
In the case of set_colsuborder the group of columns cols occupy the same positions
in DT but in a different order. See examples.