Skip to content

Instantly share code, notes, and snippets.

@kennethzfeng
Created August 29, 2014 14:18
Show Gist options
  • Select an option

  • Save kennethzfeng/3d6130bf80425b9b2ad6 to your computer and use it in GitHub Desktop.

Select an option

Save kennethzfeng/3d6130bf80425b9b2ad6 to your computer and use it in GitHub Desktop.
Clean up comma, period, etc & lowercase the text
# Clean comma and lower case text
cleanup <- function (text) {
temp <- text
# Clean up comma and period
temp <- gsub('[,.! ]', '', temp)
# To Lowercase
temp <- tolower(temp)
return(temp)
}
TEXT_STRINGS <- c("Like,", "Boom.", ".Hola", " Bo,oo!oo.")
cleanup(TEXT_STRINGS)
# > # Clean comma and lower case text
# >
# > cleanup <- function (text) {
# + temp <- text
# + # Clean up comma and period
# + temp <- gsub('[,.! ]', '', temp)
# + # To Lowercase
# + temp <- tolower(temp)
# +
# + return(temp)
# + }
# >
# > TEXT_STRINGS <- c("Like,", "Boom.", ".Hola", " Bo,oo!oo.")
# > cleanup(TEXT_STRINGS)
# [1] "like" "boom" "hola" "booooo"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment