colToRownames {FastUtils} | R Documentation |
Convert a Column to Row Names
Description
This function converts a specified column of a data frame to row names, ensuring uniqueness if necessary.
Usage
colToRownames(df, col, .remove = TRUE, .uniqueSep = ".")
Arguments
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 |
Value
A data frame with the specified column as row names. If .remove
is TRUE, the original column is removed.
See Also
Examples
# 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)
[Package FastUtils version 0.1.1 Index]