Skip to content

Instantly share code, notes, and snippets.

@Ddedalus
Created June 5, 2018 17:42
Show Gist options
  • Select an option

  • Save Ddedalus/ab110381baae4542f5693cf2747c4463 to your computer and use it in GitHub Desktop.

Select an option

Save Ddedalus/ab110381baae4542f5693cf2747c4463 to your computer and use it in GitHub Desktop.
Remove some strange characters to form a valid column name
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