Created
December 19, 2019 04:32
-
-
Save juliasilge/4806e9eeec893a5fec843f78dc4df4f2 to your computer and use it in GitHub Desktop.
Proportion of tweeted characters that are exclamation points
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(rtweet) | |
potus <- get_timeline("realDonaldTrump", n = 3200) | |
potus %>% | |
transmute(creation_date = as.Date(created_at), | |
text = str_remove_all(text, "https://t.co/[A-Za-z\\d]+"), | |
exclamations = str_extract_all(text, "\\!"), | |
exclamations = map_int(exclamations, length), | |
total_chars = nchar(text)) %>% | |
group_by(creation_date) %>% | |
summarise(percent_excl = sum(exclamations) / sum(total_chars)) %>% | |
ggplot(aes(creation_date, percent_excl)) + | |
geom_line(color = "midnightblue", size = 1.5) + | |
scale_y_continuous(labels = scales::percent_format()) + | |
labs(x = NULL, y = "Daily proportion of tweeted characters that are exclamation points!!!", | |
title = "What proportion of @realDonaldTrump's tweets are exclamation points?!?!!!!", | |
subtitle = "Sometimes, quite a lot!!!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment