Fast Reordering of Data Frame Columns
Efficiently reorder columns in a data frame (no copies). To do this by reference see also data.table::setcolorder
.
colorder(X, ..., pos = c("front", "end", "exchange")) colorderv(X, neworder = radixorder(names(X)), pos = c("front","end","exchange"), regex = FALSE, ...)
X |
a data frame or list. |
|||||||||||||||||||||
... |
for |
|||||||||||||||||||||
neworder |
a vector of column names, positive indices, a suitable logical vector, a function such as |
|||||||||||||||||||||
pos |
integer or character. Different options regarding column arrangement if
|
|||||||||||||||||||||
regex |
logical. |
X
with columns re-ordered (no deep copy).
head(colorder(mtcars, vs, cyl:hp, am)) head(colorder(mtcars, vs, cyl:hp, am, pos = "end")) head(colorder(mtcars, vs, cyl, pos = "exchange")) ## Same in standard evaluation head(colorderv(mtcars, c(8, 2:4, 9))) head(colorderv(mtcars, c(8, 2:4, 9), pos = "end")) head(colorderv(mtcars, c(8, 2), pos = "exchange"))
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.