Skip to content

Instantly share code, notes, and snippets.

@cndesantana
Created October 22, 2020 08:38
Show Gist options
  • Select an option

  • Save cndesantana/4319ac725da588bd89cdb990873f6864 to your computer and use it in GitHub Desktop.

Select an option

Save cndesantana/4319ac725da588bd89cdb990873f6864 to your computer and use it in GitHub Desktop.
Creating a network of tweets and retweets with R
### Network analysis of tweets and retweets
library(rtweet)
library(tidyverse)
tw <- search_tweets("covid19", n=15000, retryonratelimit = TRUE)
tw %>% filter(is_retweet == TRUE) %>%
mutate(Source = screen_name, Target = retweet_screen_name) %>%
group_by(Target) %>%
mutate(tottarget = n()) %>%
filter(tottarget > 50) %>%
select(Source, Target) %>%
write.csv(file="tweets_network.csv",row.names = FALSE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment