Created
July 2, 2020 15:21
-
-
Save sharlagelfand/9427ebe3d0892d08a0c52f02ef87450e to your computer and use it in GitHub Desktop.
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
library(rtweet) | |
library(dplyr) | |
library(tidytext) | |
library(stringr) | |
library(ggplot2) | |
library(ggwordcloud) | |
dc <- search_tweets( | |
"datacamp", | |
n = 1000, include_rts = FALSE | |
) | |
dc_words <- dc %>% | |
filter( | |
screen_name != "DataCamp", | |
created_at >= "2020-07-01" | |
) %>% | |
select(text) %>% | |
unnest_tokens(word, text, token = "tweets", drop = FALSE) %>% | |
filter(!str_starts(word, "@")) %>% | |
anti_join(stop_words, by = "word") | |
dc_words %>% | |
left_join(get_sentiments("afinn"), by = "word") %>% | |
filter(value <= 0) %>% | |
count(word, value) %>% | |
filter(n > 1) %>% | |
ggplot() + | |
geom_text_wordcloud(aes(label = word, size = n)) + | |
scale_size_area(max_size = 14) + | |
theme_minimal() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment