powered by
This function converts the row names of a data frame to a specified column. Note that if the specified column already exists, it is overwritten.
rownamesToCol(df, colname = "rownames")
A data frame with the row names converted to a column.
A data frame.
A character string specifying the name of the new column to contain the row names. Defaults to "rownames".
# Convert row names to a column named 'ID' df <- data.frame(Value = c(10, 20, 30)) rownames(df) <- c("A", "B", "C") rownamesToCol(df, "ID")
Run the code above in your browser using DataLab