This function takes a data frame as an argument and replaces all spaces in the row names with underscores.
fix_row_spaces(df)
A data frame
A modified data frame with spaces in row names replaced by underscores.
my_data <- data.frame("Column Name 1" = c(1, 2, 3), "Column Name 2" = c(4, 5, 6))
rownames(my_data) <- c("Row Name 1", "Row Name 2", "Row Name 3")
fix_row_spaces(my_data)
#> Column.Name.1 Column.Name.2
#> Row_Name_1 1 4
#> Row_Name_2 2 5
#> Row_Name_3 3 6
# Returns a data frame with row names where spaces are replaced by underscores.