Created
December 7, 2016 15:43
-
-
Save herbps10/de608d8b3b6771c4330fb01f8e4f473f to your computer and use it in GitHub Desktop.
Twitter word cloud
This file contains 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
library(tidyverse) | |
library(tm) | |
library(SnowballC) | |
library(wordcloud) | |
library(RColorBrewer) | |
setup_twitter_oauth(consumer_key = "...", consumer_secret = "...") | |
results <- searchTwitter("#EHSFEST", n = 1000) %>% | |
twListToDF() | |
pal <- brewer.pal(6, "Dark2") | |
corpus <- Corpus(VectorSource(results$text)) %>% | |
tm_map(PlainTextDocument) %>% | |
tm_map(removePunctuation) %>% | |
tm_map(content_transformer(tolower)) %>% | |
tm_map(removeWords, stopwords('english')) %>% | |
tm_map(removeWords, c('ehsfest', 'niehs', 'amp', 'durham', "httpstco", "httpstcol6pul1fixv", "httpstcofasxogimq0", "can", "our")) | |
wordcloud(corpus, colors = pal, max.words = 100, rot.per = FALSE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment