Attaching package: 'rtweet'
The following object is masked from 'package:purrr':
flatten
### sentiment analysis # get the tweets from the most followed twitter account - @barackobamaauth_as('create_token')
Reading auth from '/Users/haydenbharper/Library/Preferences/org.R-project.R/R/
rtweet/create_token.rds'
tweets <-search_tweets("@BarackObama", n =500, include_rts =FALSE)# split the data into single wordsd <- tweets |>select(text) |>unnest_tokens(output = word, input = text)## Step 3: Word Counts ----------------d %>%# count the number of times each word was usedcount(word) %>%# arrange the new count data by popularityarrange(-n)
# A tibble: 2,205 × 2
word n
<chr> <int>
1 barackobama 514
2 joebiden 339
3 the 193
4 you 148
5 https 121
6 t.co 121
7 to 112
8 in 93
9 a 92
10 of 85
# … with 2,195 more rows
# ℹ Use `print(n = ...)` to see more rows
get_stopwords()
# A tibble: 175 × 2
word lexicon
<chr> <chr>
1 i snowball
2 me snowball
3 my snowball
4 myself snowball
5 we snowball
6 our snowball
7 ours snowball
8 ourselves snowball
9 you snowball
10 your snowball
# … with 165 more rows
# ℹ Use `print(n = ...)` to see more rows