reorderColumns | R Documentation |
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.
reorderColumns(df, vars)
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. |
A copy of the input data.frame, with columns rearranged per vars
{
df <- data.frame(Time=c(1,2), In=c(2,3), Out=c(3,4), Files=c(4,5))
datarobot:::reorderColumns(df, c("In" = 3, "Time" = 4))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.