Visualise networks of Twitter interactions.
Updated the package to better suit
install.packages("graphTweets") # CRAN release v0.4 devtools::install_github("JohnCoene/graphTweets") # dev version
gt_edges- get edges.
gt_nodes- get nodes, with or without metadata.
gt_dyn- create dynamic graph.
gt_save- save the graph to file
gt_collect- collect nodes and edges.
NEWS.md for changes.
Functions are meant to be run in a specific order.
One can only know the nodes of a network based on the edges, so run them in that order. However, you can build a graph based on edges alone:
tweets %>% gt_edges(text, screen_name) %>% gt_graph() %>% plot(., vertex.size = igraph::degree(.) * 10)
This is useful if you are building a large graph and don’t need any meta data on the nodes (other than those you can compute from the graph, i.e.:
degree like in the example above). If you need meta data on the nodes use
tweets %>% gt_edges(text, screen_name) %>% gt_nodes(meta = TRUE) %>% # set meta to TRUE gt_graph() %>% plot(., vertex.size = v(.)$followers_count) # size nodes by follower count.
library(rtweet) # Sys.setlocale("LC_TIME", "English") tweets <- search_tweets("#rstats") library(graphTweets) # simple network tweets %>% gt_edges(text, screen_name) %>% # get edges gt_nodes %>% # get nodes gt_graph %>% # build igraph object plot(.) # dynamic graph tweets %>% gt_edges(text, screen_name, "created_at") %>% # add created time gt_nodes(TRUE) %>% gt_dyn %>% # make dynamic gt_save # save as .graphml