Two core functions of graphTweets are
gt_co_edges which come with sister functions:
gt_co_edges_bind that help bind edges together to build more complex graphs.
Let’s get some tweets again.
In other sections we detailed, amongst other things, how to build 1) a network of hashtags and 2) a network of users connected to the hashtags they use in their tweets: how about we bind these two?
net <- tweets %>% gt_co_edges(mentions_screen_name) %>% gt_edges_bind(screen_name, hashtags) %>% gt_nodes() %>% gt_collect() c(edges, nodes) %<-% net library(dplyr) #> #> Attaching package: 'dplyr' #> The following objects are masked from 'package:stats': #> #> filter, lag #> The following objects are masked from 'package:base': #> #> intersect, setdiff, setequal, union edges <- edges %>% mutate(id = 1:n()) nodes <- nodes %>% mutate( id = nodes, label = id, size = n ) library(sigmajs) #> Welcome to sigmajs #> #> Docs: sigmajs.john-coene.com sigmajs() %>% sg_nodes(nodes, id, label, size) %>% sg_edges(edges, id, source, target) %>% sg_cluster( colors = c( "#0084b4", "#00aced", "#1dcaff", "#c0deed" ) ) %>% sg_layout(layout = igraph::layout_components) %>% sg_neighbours() %>% sg_settings( minNodeSize = 1, maxNodeSize = 3, defaultEdgeColor = "#a3a3a3", edgeColor = "default" )
Functions are built in such a way to you can bind any edges together.