Created
October 7, 2019 16:01
-
-
Save monogenea/b9419bfbe4f708180e381c48bb7b1715 to your computer and use it in GitHub Desktop.
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
# Identify tweets containing any of the characters names (0/1) | |
popularity <- as.data.frame(lapply(gotChars, function(x){ | |
as.integer(sapply(tkn, function(k){any(k %in% x)})) | |
})) | |
# Write colnames | |
colnames(popularity) <- gotChars | |
# Add column with corresponding EST time | |
popularity$created_at <- allTweets$created_at | |
# Reshape w.r.t. created_at, select hits | |
popularity <- reshape2::melt(popularity, id.vars = "created_at") | |
popularity <- slice(popularity, which(value == 1)) | |
# Determine the time all six episodes were aired (9pm EST every Sunday starting 14th April) | |
epAirTime <- ymd_hms("2019-04-14 21:00:00",tz="EST") + dweeks(0:5) | |
# Plot ggridge-style | |
ggplot(popularity, aes(x = created_at, y = variable, fill = variable)) + | |
geom_density_ridges() + | |
geom_vline(xintercept = epAirTime, linetype = "dashed", | |
color = "red",show.legend = T) + | |
theme_ridges() + | |
theme(legend.position = "none") + | |
annotate("text", x = epAirTime, y = 20.75, | |
label = paste0("Ep.", c(1:6)) ,hjust = 1.25) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment