An analysis of…

This analysis of the pop’s twitter timeline focuses on …. wikipedia: http://rmarkdown.rstudio.com.

First, we need to load our packages:

library(rtweet)
library(tidyverse)
library(tidytext)
library(rtweet)
library(wordcloud2)

Now, let’s get the Pope’s timeline:

  gates <- get_timeline('billgates', n = 3200)

The next step is to remove stop words and count word frequency. We’ll remove the extra words ‘t.co,’ ‘http,’ etc., and generate a wordcloud

gates %>% 
  unnest_tokens(word, text) %>% 
  anti_join(stop_words) %>% 
  filter(!word %in% c('t.co', 'https', 'http', 'amp')) %>% 
  count(word, sort = TRUE) %>% 
  head(20) %>% 
  knitr::kable()
## Joining, by = "word"
word n
world 318
people 268
i’m 218
progress 173
lives 166
health 160
change 153
polio 151
book 149
energy 145
fight 144
climate 140
global 140
it’s 132
here’s 125
read 124
time 113
life 111
malaria 101
students 99
gates %>% 
  unnest_tokens(word, text) %>% 
  anti_join(stop_words) %>% 
  filter(!word %in% c('t.co', 'https', 'http', 'amp')) %>% 
  count(word, sort = TRUE) %>% 
  wordcloud2()
## Joining, by = "word"