Created
August 29, 2014 14:18
-
-
Save kennethzfeng/3d6130bf80425b9b2ad6 to your computer and use it in GitHub Desktop.
Clean up comma, period, etc & lowercase the text
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
| # 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