Skip to contents

This function reorders the columns of a dataframe according to the specified column order.

Usage

reorderColumns(df, columnOrder)

Arguments

df

The input dataframe.

columnOrder

A vector specifying the desired order of columns.

Value

A dataframe with columns reordered according to the specified column order.

Examples

# Example dataframe
df <- data.frame(A = 1:3, B = 4:6, C = 7:9)

# Define the desired column order
columnOrder <- c("B", "C", "A")

# Reorder the columns of the dataframe
df <- reorderColumns(df, columnOrder)