rownamesToCol | R Documentation |
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")
df |
A data frame. |
colname |
A character string specifying the name of the new column to contain the row names. Defaults to "rownames". |
A data frame with the row names converted to a column.
# 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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.