Skip to content

Instantly share code, notes, and snippets.

@WilsonMongwe
Created October 7, 2017 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WilsonMongwe/6245b652d41f2eaebe821c80ebc341da to your computer and use it in GitHub Desktop.
Save WilsonMongwe/6245b652d41f2eaebe821c80ebc341da to your computer and use it in GitHub Desktop.
#Clean the tweets by removing silly symblos/characters
cleanTweets <- function(tweets)
{
tweets = gsub("@", "", tweets)
tweets = gsub("@\\w+", " ", tweets)
tweets = gsub("https", "", tweets)
tweets <- gsub("[ |\t]{2,}", " ", tweets)
tweets <- gsub("[ |\t]{2,}", " ", tweets)
tweets <- gsub("amp", " ", tweets)
tweets <- gsub("^ ", "", tweets)
tweets <- gsub(" $", "", tweets)
tweets <- gsub(" +", " ", tweets)
tweets <- unique(tweets)
return(tweets)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment