Skip to content

Instantly share code, notes, and snippets.

@cndesantana
Created June 6, 2020 16:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cndesantana/430589fcca14d64ea6e71f1464fc7374 to your computer and use it in GitHub Desktop.
Save cndesantana/430589fcca14d64ea6e71f1464fc7374 to your computer and use it in GitHub Desktop.
criando figura com parcial de enquete feita no twitter
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