library(tidyverse)
## ── Attaching packages ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 3.0.0 ✔ purrr 0.2.5
## ✔ tibble 1.4.2 ✔ dplyr 0.7.6
## ✔ tidyr 0.8.1 ✔ stringr 1.3.1
## ✔ readr 1.1.1 ✔ forcats 0.3.0
## ── Conflicts ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
headlines_all <- read_rds("~/local_docker/brexit_sentiment/data/mutineers_headlines_processed.rds")
mutineers_tweets <- read_rds("~/local_docker/brexit_sentiment/data/mutineers_RT_metrics.rds")
headlines_all %>%
sample_n(1000) %>%
rmarkdown:::print.paged_df()
headlines_all %>%
sample_n(1000) %>%
write_csv("../data/headline_metrics_sample.csv")
headlines_all %>%
skimr::skim()
## Skim summary statistics
## n obs: 1085
## n variables: 18
##
## ── Variable type:character ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## variable missing complete n min max empty n_unique
## BYLINE 92 993 1085 7 162 0 471
## DATE 0 1085 1085 17 40 0 727
## HEADLINE 0 1085 1085 14 523 0 1059
## headline_id 0 1085 1085 1 4 0 1041
## headline_low 0 1085 1085 14 523 0 1059
## LENGTH 0 1085 1085 7 11 0 643
## PUBLICATION 0 1085 1085 10 32 0 21
## publication_format 0 1085 1085 6 10 0 3
## publication_politics 0 1085 1085 4 6 0 3
## publication_simplified 0 1085 1085 5 15 0 11
## search_term 0 1085 1085 5 10 0 8
## SECTION 347 738 1085 5 44 0 203
##
## ── Variable type:Date ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## variable missing complete n min max median
## date_parsed 0 1085 1085 2017-11-11 2017-11-22 2017-11-16
## n_unique
## 12
##
## ── Variable type:numeric ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## variable missing complete n mean sd p0 p25 p50 p75 p100
## topic_britishness 0 1085 1085 0.0037 0.061 0 0 0 0 1
## topic_economy 0 1085 1085 0.22 0.41 0 0 0 0 1
## topic_health 0 1085 1085 0.015 0.12 0 0 0 0 1
## topic_immigration 0 1085 1085 0.07 0.26 0 0 0 0 1
## topic_sovereignty 0 1085 1085 0.041 0.2 0 0 0 0 1
## hist
## ▇▁▁▁▁▁▁▁
## ▇▁▁▁▁▁▁▂
## ▇▁▁▁▁▁▁▁
## ▇▁▁▁▁▁▁▁
## ▇▁▁▁▁▁▁▁
mutineers_tweets %>%
sample_n(1000) %>%
rmarkdown:::print.paged_df()
mutineers_tweets %>%
sample_n(1000) %>%
write_csv("../data/tweet_metrics_sample.csv")
mutineers_tweets %>%
skimr::skim()
## Skim summary statistics
## n obs: 2637070
## n variables: 46
##
## ── Variable type:character ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## variable missing complete n min max empty n_unique
## date 0 2637070 2637070 10 10 0 11
## description 321121 2315949 2637070 1 311 0 1193210
## keyword 0 2637070 2637070 4 20 0 97
## likes 0 2637070 2637070 1 6 0 2157
## mentions_screen_name 1493667 1143403 2637070 1 644 0 627707
## replies 0 2637070 2637070 1 4 0 437
## retweets 0 2637070 2637070 1 6 0 1402
## screen_name 0 2637070 2637070 1 17 0 1412630
## status_id 0 2637070 2637070 18 18 0 2637070
## text 0 2637070 2637070 1 1008 0 2553858
## time 0 2637070 2637070 8 8 0 86400
## url 1629178 1007892 2637070 14 99 0 505364
## user_is_media_why 321121 2315949 2637070 3 87 0 2097
## username 0 2637070 2637070 1 17 0 1412666
##
## ── Variable type:factor ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## variable missing complete n n_unique
## user_is_celebrity 0 2637070 2637070 2
## user_is_media 321121 2315949 2637070 2
## user_is_MP 0 2637070 2637070 2
## user_is_police 0 2637070 2637070 2
## top_counts ordered
## 0: 2636996, 1: 74, NA: 0 FALSE
## 0: 2159459, NA: 321121, 1: 156490 FALSE
## 0: 2636274, 1: 796, NA: 0 FALSE
## 0: 2636986, 1: 84, NA: 0 FALSE
##
## ── Variable type:integer ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## variable missing complete n mean sd p0 p25
## class_antimuslim2 0 2637070 2637070 0.027 0.16 0 0
## class_countersp 0 2637070 2637070 2.24 1.28 0 2
## class_race 0 2637070 2637070 0.0068 0.082 0 0
## contains_hashtag 0 2637070 2637070 0.18 0.39 0 0
## contains_url 0 2637070 2637070 0.38 0.48 0 0
## followers_count 0 2637070 2637070 14145.98 308008.15 0 178
## friends_count 0 2637070 2637070 1929.09 10252.4 0 187
## hashtag_freq 0 2637070 2637070 0.4 1.29 0 0
## hour_of_day 0 2637070 2637070 12.69 6.93 0 7
## retweet_count 0 2637070 2637070 2.27 122.36 0 0
## statuses_count 0 2637070 2637070 53090.37 262797.07 0 4126
## url_freq 0 2637070 2637070 0.42 0.59 0 0
## p50 p75 p100 hist
## 0 0 1 ▇▁▁▁▁▁▁▁
## 3 3 4 ▂▁▁▁▁▇▁▁
## 0 0 1 ▇▁▁▁▁▁▁▁
## 0 0 1 ▇▁▁▁▁▁▁▂
## 0 1 1 ▇▁▁▁▁▁▁▅
## 602 2006 7.7e+07 ▇▁▁▁▁▁▁▁
## 499 1356 1590927 ▇▁▁▁▁▁▁▁
## 0 0 47 ▇▁▁▁▁▁▁▁
## 14 19 23 ▆▅▅▅▇▇▇▇
## 0 0 108349 ▇▁▁▁▁▁▁▁
## 15057 45058 3.2e+07 ▇▁▁▁▁▁▁▁
## 0 1 7 ▇▅▁▁▁▁▁▁
##
## ── Variable type:logical ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## variable missing complete n mean count
## verified 0 2637070 2637070 0.027 FAL: 2565684, TRU: 71386, NA: 0
##
## ── Variable type:numeric ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## variable missing complete n mean sd p0 p25 p50 p75 p100
## commute_eve 0 2637070 2637070 0.11 0.31 0 0 0 0 1
## commute_morn 0 2637070 2637070 0.12 0.32 0 0 0 0 1
## day_of_week 0 2637070 2637070 3.57 2 1 2 3 5 7
## evening 0 2637070 2637070 0.25 0.43 0 0 0 1 1
## friday 0 2637070 2637070 0.094 0.29 0 0 0 0 1
## monday 0 2637070 2637070 0.17 0.37 0 0 0 0 1
## night 0 2637070 2637070 0.21 0.41 0 0 0 0 1
## saturday 0 2637070 2637070 0.099 0.3 0 0 0 0 1
## sunday 0 2637070 2637070 0.13 0.34 0 0 0 0 1
## thursday 0 2637070 2637070 0.096 0.3 0 0 0 0 1
## tuesday 0 2637070 2637070 0.2 0.4 0 0 0 0 1
## user_is_other 321113 2315957 2637070 0.93 0.25 0 1 1 1 1
## wednesday 0 2637070 2637070 0.21 0.41 0 0 0 0 1
## work 0 2637070 2637070 0.31 0.46 0 0 0 1 1
## hist
## ▇▁▁▁▁▁▁▁
## ▇▁▁▁▁▁▁▁
## ▆▇▇▃▁▃▃▅
## ▇▁▁▁▁▁▁▃
## ▇▁▁▁▁▁▁▁
## ▇▁▁▁▁▁▁▂
## ▇▁▁▁▁▁▁▂
## ▇▁▁▁▁▁▁▁
## ▇▁▁▁▁▁▁▁
## ▇▁▁▁▁▁▁▁
## ▇▁▁▁▁▁▁▂
## ▁▁▁▁▁▁▁▇
## ▇▁▁▁▁▁▁▂
## ▇▁▁▁▁▁▁▃
##
## ── Variable type:POSIXct ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## variable missing complete n min max median
## created_at 0 2637070 2637070 2017-11-11 2017-11-21 2017-11-16
## n_unique
## 866364