R data frame rearrange columns code example
Example: r - reorder columns in data frame
# Reorder by column name
df <- df[c("A", "B", "C")]
# Reorder by column index
df <- df[c(1, 3, 2)]
# Reorder by column name
df <- df[c("A", "B", "C")]
# Reorder by column index
df <- df[c(1, 3, 2)]