graphTweets not only allows to build graphs of interactions between users. It also lets you visualise what hashtag users use in their tweets and which hashtags are used together in the same tweets.

Hashtags Co-mentions

We can also build networks of hashtags co-mentions; when two or more hashtags are used in the same tweet they are connected on the graph.

Let’s look at the hashtags associated with #rstats

For this network use gt_edges_hashes and simply pass the hashtags column as it’s all that is needed.

net <- tweets %>% 
  gt_co_edges(hashtags) %>%
  gt_nodes() %>% 
  gt_collect()

c(edges, nodes) %<-% net

Then again, we’ll use sigmajs for the visualisation. Since we got tweets on #rstats we will remove this node, it will be connected to all other hashtags. Make sure you remove it from both nodes and edges.

Users co-mentions

We can also build networks of co-mentions where users that are @tagged in the same tweet are connected. We’ll collect more tweets, with a slightly different queries to ensure that the tweets include @mentions.

When preparing the graph we simply pass mentions_screen_name instead of hashtags as we did before.