Created
June 6, 2020 16:30
-
-
Save cndesantana/430589fcca14d64ea6e71f1464fc7374 to your computer and use it in GitHub Desktop.
criando figura com parcial de enquete feita no twitter
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(tidyverse) | |
library(tidyr) | |
library(tidytext) | |
library(tm) | |
tw = search_tweets("to:RodZeidan",n= 8000) | |
tw_pesquisa = tw %>% filter(reply_to_status_id == "1269113444646649857", !is_retweet, !is_quote) | |
nresp = nrow(tw_pesquisa) | |
p1 = tw_pesquisa %>% | |
unnest_tokens(word, text) %>% | |
anti_join( | |
tibble(word=c(stopwords("portuguese"),"admiro","ainda","gosto","honrosa","menção","é","sei","pra","intelectual","história"), | |
lexicon="custom") | |
) %>% | |
filter(word != "rodzeidan") %>% | |
mutate(word = tolower(word)) %>% | |
count(word) %>% | |
arrange(n) %>% | |
tail(30) %>% | |
ggplot(aes(x = reorder(word,n), y = n)) + | |
geom_bar(stat="identity", fill = "red4")+ | |
geom_text(aes(x = reorder(word,n), y = n, label=n, hjust=-0.1))+ | |
labs(title = "Qual o/a maior intelectual brasileiro/a?",subtitle = paste0("Resultado parcial as 13:20 ( ",nresp," respostas)"), x="Nomes",y="# de citas")+ | |
coord_flip()+ | |
theme_bw() | |
png("maior_intelectual_brasileiro.png",width=3200,height=1800,res=300) | |
print(p1) | |
dev.off() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment