Skip to content

Instantly share code, notes, and snippets.

@fernandobarbalho
Created January 21, 2022 19:34
Show Gist options
  • Save fernandobarbalho/f53c9a40b4c1679920aa0e4437999b5f to your computer and use it in GitHub Desktop.
Save fernandobarbalho/f53c9a40b4c1679920aa0e4437999b5f to your computer and use it in GitHub Desktop.
elza<- rtweet::search_tweets("elza", n=18000, include_rts = FALSE )
tidy_elza<-
elza %>%
unnest_tokens(word, text, token = "tweets", strip_punct = TRUE, strip_url = TRUE) %>%
group_by(word) %>%
filter(n() > 5) %>%
ungroup() %>%
select(word)
library(stopwords)
library(tibble)
stopword <- as_tibble(stopwords::stopwords("pt"))
stopword <- rename(stopword, word=value)
newstopwords_elza <- tibble(word = c("é", "t","n","q","vc","h", "pra","via","ñ","vai"))
stop_words_users_elza<-
tidy_twitter %>%
filter(str_detect(word, "@")) %>%
select(word)
stop_words_users_elza_sem_arroba<-
tidy_twitter %>%
filter(str_detect(word, "@")) %>%
mutate(word=str_sub(word,2,200)) %>%
select(word)
stopwords_full_elza <- bind_rows (stopword, stop_words_users_elza,newstopwords_elza, stop_words_users_elza_sem_arroba)
tb_elza <- anti_join(tidy_elza, stopwords_full_elza, by = 'word')
word_count_elza <- count(tb_elza, word, sort = TRUE)
##Nuvem de palavras
library(wordcloud)
tb_elza %>%
filter(!word %in% c("elza","soares")) %>%
count(word)%>%
with(wordcloud(word,n,max.words = 150, colors=brewer.pal(6,"Dark2"),random.order=FALSE))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment