I have a dataframe with column 0 having the variables:
How do I get this dataframe to have column 0 as the numbered column and the current column 0 to be a "variable" column (which would be column 1)? I have shown an example below:
We can use rownames_to_column
from tibble
library(tibble)
df1 <- rownames_to_column(df1, "Variable")
Or using base R
df1$Variable <- row.names(df1)
row.names(df1) <- NULL