## ── Attaching packages ──────────────────────────────────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 3.2.1     ✔ purrr   0.3.2
## ✔ tibble  2.1.3     ✔ dplyr   0.8.3
## ✔ tidyr   1.0.0     ✔ stringr 1.4.0
## ✔ readr   1.3.1     ✔ forcats 0.4.0
## ── Conflicts ─────────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## 
## Attaching package: 'twitteR'
## The following objects are masked from 'package:dplyr':
## 
##     id, location
## 
## Attaching package: 'reshape2'
## The following object is masked from 'package:tidyr':
## 
##     smiths
## Loading required package: RColorBrewer
## 
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
## 
##     date
## 
## Attaching package: 'rtweet'
## The following object is masked from 'package:twitteR':
## 
##     lookup_statuses
## The following object is masked from 'package:purrr':
## 
##     flatten
## # A tibble: 6 x 90
##   user_id status_id created_at          screen_name text  source
##   <chr>   <chr>     <dttm>              <chr>       <chr> <chr> 
## 1 230285… 12030668… 2019-12-06 21:41:06 Ruffitup    "htt… Twitt…
## 2 5741722 12030668… 2019-12-06 21:41:06 nprpolitics NEW:… Socia…
## 3 5741722 12030653… 2019-12-06 21:35:06 nprpolitics The … Socia…
## 4 214939… 12030668… 2019-12-06 21:41:05 roblynnm    @Spe… Twitt…
## 5 118271… 12030668… 2019-12-06 21:41:04 ___Lvcifer… @rea… Twitt…
## 6 118806… 12030668… 2019-12-06 21:41:04 DisgustedN… "@bl… Twitt…
## # … with 84 more variables: display_text_width <dbl>,
## #   reply_to_status_id <chr>, reply_to_user_id <chr>,
## #   reply_to_screen_name <chr>, is_quote <lgl>, is_retweet <lgl>,
## #   favorite_count <int>, retweet_count <int>, quote_count <int>,
## #   reply_count <int>, hashtags <list>, symbols <list>, urls_url <list>,
## #   urls_t.co <list>, urls_expanded_url <list>, media_url <list>,
## #   media_t.co <list>, media_expanded_url <list>, media_type <list>,
## #   ext_media_url <list>, ext_media_t.co <list>,
## #   ext_media_expanded_url <list>, ext_media_type <chr>,
## #   mentions_user_id <list>, mentions_screen_name <list>, lang <chr>,
## #   quoted_status_id <chr>, quoted_text <chr>, quoted_created_at <dttm>,
## #   quoted_source <chr>, quoted_favorite_count <int>,
## #   quoted_retweet_count <int>, quoted_user_id <chr>,
## #   quoted_screen_name <chr>, quoted_name <chr>,
## #   quoted_followers_count <int>, quoted_friends_count <int>,
## #   quoted_statuses_count <int>, quoted_location <chr>,
## #   quoted_description <chr>, quoted_verified <lgl>,
## #   retweet_status_id <chr>, retweet_text <chr>,
## #   retweet_created_at <dttm>, retweet_source <chr>,
## #   retweet_favorite_count <int>, retweet_retweet_count <int>,
## #   retweet_user_id <chr>, retweet_screen_name <chr>, retweet_name <chr>,
## #   retweet_followers_count <int>, retweet_friends_count <int>,
## #   retweet_statuses_count <int>, retweet_location <chr>,
## #   retweet_description <chr>, retweet_verified <lgl>, place_url <chr>,
## #   place_name <chr>, place_full_name <chr>, place_type <chr>,
## #   country <chr>, country_code <chr>, geo_coords <list>,
## #   coords_coords <list>, bbox_coords <list>, status_url <chr>,
## #   name <chr>, location <chr>, description <chr>, url <chr>,
## #   protected <lgl>, followers_count <int>, friends_count <int>,
## #   listed_count <int>, statuses_count <int>, favourites_count <int>,
## #   account_created_at <dttm>, verified <lgl>, profile_url <chr>,
## #   profile_expanded_url <chr>, account_lang <lgl>,
## #   profile_banner_url <chr>, profile_background_url <chr>,
## #   profile_image_url <chr>

Assignment

I’m analyzing the word “impeachment” on Twitter. I listed the percentage of the sources of the tweets, and put the top 5 sources in a column chart. I also listed the top 6 of each sentiment in the tweets, and made a chart showing the positive and negative words associated with “impeachment”.

Source

## Selecting by percent_of_tweets
## # A tibble: 5 x 3
##   source                  n percent_of_tweets
##   <chr>               <int>             <dbl>
## 1 Twitter for iPhone    279             0.279
## 2 Twitter Web App       240             0.24 
## 3 Twitter for Android   195             0.195
## 4 Twitter Web Client    127             0.127
## 5 Twitter for iPad       38             0.038

## Joining, by = "word"
## Joining, by = "word"

Sentiment

## # A tibble: 6 x 3
##   word             n sentiment
##   <chr>        <int> <chr>    
## 1 support         21 Positive 
## 2 top             17 Positive 
## 3 won             17 Positive 
## 4 win             10 Positive 
## 5 intelligence     7 Positive 
## 6 protect          7 Positive
## # A tibble: 6 x 3
##   word         n sentiment
##   <chr>    <int> <chr>    
## 1 sham        29 Negative 
## 2 concern     23 Negative 
## 3 abuse       18 Negative 
## 4 breaking    16 Negative 
## 5 baseless    12 Negative 
## 6 hoax        12 Negative