Skip to content

Instantly share code, notes, and snippets.

@mcguinlu
Last active January 25, 2021 10:07
Show Gist options
  • Save mcguinlu/8b634fe9f35c794cdb898bacc24e83bb to your computer and use it in GitHub Desktop.
Save mcguinlu/8b634fe9f35c794cdb898bacc24e83bb to your computer and use it in GitHub Desktop.
library(rtweet)
library(tidyr)
library(dplyr)
library(ggplot2)
rt1 <- search_tweets(
"#ESMARConf2021", n = 20000, include_rts = TRUE
)
rt2 <- search_tweets(
"#ESMARConf", n = 20000, include_rts = TRUE
)
rt3 <- search_tweets(
"#ESMARConf2020", n = 20000, include_rts = TRUE
)
rt <- rbind(rt1,rt2,rt3) %>%
as_tibble() %>%
select(screen_name, text, created_at, is_quote, is_retweet, status_id)
write.csv(rt, "ESMAR_tweets.csv",row.names = FALSE)
p <-
rt %>%
filter(is_retweet == FALSE) %>%
group_by(screen_name) %>%
summarise(N= n()) %>%
filter(!(screen_name %in%c("nealhaddaway",
"MetaEvidence",
"Ed_pheasant",
"eshackathon",
"mcguinlu",
"campbellreviews"))) %>%
arrange(desc(N)) %>%
filter(N >2) %>%
ggplot(aes(x = N, y = reorder(screen_name, N))) +
geom_col(colour = "#4fb3a9", fill = "#4fb3a9") +
geom_text(aes(label = N), hjust = -0.5) +
labs(x = "Number of tweets",
y = "Username",
title = "Top #ESMARConf2021 tweeters - Day 1 ") +
theme_minimal()
p
rt %>%
group_by(is_retweet) %>%
summarise(N=n())
ggsave("ESMARCConf plot.png", p)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment