Skip to content

Instantly share code, notes, and snippets.

@benwhalley
Created June 13, 2018 08:49
Show Gist options
  • Save benwhalley/592495ecf45b0bfee7b1332dd4ac31df to your computer and use it in GitHub Desktop.
Save benwhalley/592495ecf45b0bfee7b1332dd4ac31df to your computer and use it in GitHub Desktop.
Make strings url and filename friendly (akin to Django's eponymous function)
slugify <- function(text){
text %>%
tolower() %>%
str_trim() %>%
str_replace_all('[\\s-]+', "-") %>%
str_remove_all('[^\\w-]+')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment