powered by
This function removes any non-alphanumeric characters from both the row and column names of a given data frame.
fix_special_characters_in_names(df)
A data frame with all non-alphanumeric characters removed from the column and row names.
A data frame with non-alphanumeric characters in the column or row names.
df <- data.frame("Col1!" = c(1, 2, 3), "Col2?" = c(4, 5, 6)) rownames(df) <- c("Row1@", "Row2#", "Row3$") fix_special_characters_in_names(df)
Run the code above in your browser using DataLab