Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 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
You can’t perform that action at this time.