colToRownames | R Documentation |
This function converts a specified column of a data frame to row names, ensuring uniqueness if necessary.
colToRownames(df, col, .remove = TRUE, .uniqueSep = ".")
df |
A data frame. |
col |
A character string specifying the name of the column to convert to row names. |
.remove |
A logical indicating whether to remove the selected column after converting to row names. Default is TRUE. |
.uniqueSep |
A character string to separate duplicate row names when
ensuring uniqueness
with |
A data frame with the specified column as row names. If .remove
is TRUE, the original column is removed.
mutateToRownames()
# Convert the 'ID' column to row names
df <- data.frame(ID = c("A", "B", "C"), Value = c(10, 20, 30))
colToRownames(df, "ID")
# Convert the 'ID' column to row names and keep the column
df <- data.frame(ID = c("A", "B", "C"), Value = c(10, 20, 30))
colToRownames(df, "ID", .remove = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.