fix_row_names {fixr} | R Documentation |
Fix row names of a data frame
Description
This function removes any leading "X." or "X" from the row names of a data frame, replaces any "." with "_", removes any leading or trailing symbols and spaces, and ensures that there is only one underscore between two words. Additionally, if there are duplicate row names, the function appends a number to each duplicate row name to make it unique.
Usage
fix_row_names(data)
Arguments
data |
a data frame with improperly formatted row names |
Value
a modified data frame with fixed row names
Examples
my_data <- data.frame(" Col1" = c(1, 2, 3), "Col.2" = c(4, 5, 6), check.names = FALSE)
rownames(my_data) <- c(" Row1", " Row.2", "Row.3 ")
fix_row_names(my_data)
[Package fixr version 0.1.0 Index]