Skip to content

Instantly share code, notes, and snippets.

@danielecook
Created February 3, 2020 09:07
Show Gist options
  • Save danielecook/b610f4ffe36b6027cdcefd3eb72c7ede to your computer and use it in GitHub Desktop.
Save danielecook/b610f4ffe36b6027cdcefd3eb72c7ede to your computer and use it in GitHub Desktop.
Slugify
slugify <- function(str) {
# Function for cleaning up column names
str %>%
stringr::str_replace_all("[^a-zA-Z0-9-]", "_") %>%
stringr::str_replace_all("-+", "_") %>%
stringr::str_replace("[_]{2,50}", "_") %>%
stringr::str_replace("_$", "") %>%
tolower()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment