View source: R/set_cols_first.R
set_cols_first | R Documentation |
Reorder columns of a data.table
(via setcolorder
) so that particular columns
appear first (or last), or in a particular order.
set_cols_first(DT, cols, intersection = TRUE)
set_cols_last(DT, cols, intersection = TRUE)
set_colsuborder(DT, cols, intersection = TRUE)
DT |
A data.table. |
cols |
Character vector of columns to put before (after) all others or, in the case of |
intersection |
Use the intersection of the names of |
In the case of set_colsuborder
the group of columns cols
occupy the same positions
in DT
but in a different order. See examples.
library(data.table)
DT <- data.table(y = 1:5, z = 11:15, x = letters[1:5])
set_cols_first(DT, "x")[]
set_cols_last(DT, "x")[]
set_colsuborder(DT, c("x", "y"))[]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.