Answers for "columns of a table R"

R
0

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)]
Posted by: Guest on July-27-2020
0

reorder columns in r

col_order <- c("Species", "Petal.Width", "Sepal.Length",
               "Sepal.Width", "Petal.Length")
my_data2 <- my_data[, col_order]
my_data2

# or
my_data2 <- my_data[, c(5, 4, 1, 2, 3)]
Posted by: Guest on February-27-2020

Code answers related to "columns of a table R"

Browse Popular Code Answers by Language