Learn R Programming

PAutilities (version 1.1.0)

df_reorder: Reorder the columns of a data frame

Description

Reorder the columns of a data frame

Usage

df_reorder(df, columns, after)

Value

The reordered data frame

Arguments

df

the data frame

columns

the column(s) to move (either as character names or numeric indices)

after

the column after which to insert columns (must be a scalar, either a character name or a numeric index)

Examples

Run this code
df <- data.frame(a = 1:10, b = 11:20, c = 21:30, d = 31:40)
df_reorder(df, 2:3, "d")
df_reorder(df, c("c", "d"), "a")

Run the code above in your browser using DataLab