Created
June 5, 2018 17:42
-
-
Save Ddedalus/ab110381baae4542f5693cf2747c4463 to your computer and use it in GitHub Desktop.
Remove some strange characters to form a valid column name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| colnames()%<>% trimws %>% gsub("\\(%\\)", "pp", .) %>% | |
| make.names %>% gsub("\\.+", "\\.", .) | |
| # whitespace from the beginning/end is trimmed | |
| # replaces (%) with a "pp" abbreviation for percentage | |
| # all white chars are subed with a dot | |
| # multiple dots are concatenated to a single one | |
| require(magrittr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment