reorderColumns: Reorder the columns in a data.frame
Description
This function reorders columns in a data.frame without relying on dplyr or
data.table. You only need to specify the columns that should be moved; all
others will be slotted in the gaps. Invalid columns are ignored.
Usage
reorderColumns(df, vars)
Value
A copy of the input data.frame, with columns rearranged per vars
Arguments
df
data.frame with named columns.
vars
integer. named vector where the names represent column names in
df that should be moved. The value of each item is the new location of
that column.