Twitter is great source of "network data", plus thanks to Michael Kearney's rtweet package the data is extremely easy to access.
The idea is to pull tweets on a specific topic (given a boolean search) and graph the network of retweets, this gives an idea of how conversations spread throughout Twitter. We use graphTweets to build the latter.
Below we pull 15,000 tweets that use the #rstats hashtag using the retweets filter to optimise the query (we're only interested in retweets).
tweets <- rtweet::search_tweets("#rstats filter:retweets", n = 15000L)
Then I use graphTweets to build the network of retweets, including "quotes" (retweets with a comment).
library(graphTweets) net <- tweets %>% gt_edges(screen_name, retweet_screen_name) %>% gt_edges_bind(screen_name, quoted_screen_name) %>% gt_nodes() %>% gt_collect()
graphTweets actually returns a list of nodes and edges. After renaming "edges" to "links" we can simply pass this object straight to our initialisation function.
library(grapher) # rename names(net) <- c("links", "nodes") graph(net) %>% graph_offline_layout(steps = 100) %>% scale_node_size(n, c(10, 50)) %>% hide_long_links(100) %>% scale_link_color_coords()