Chapter 8 Hashtags
The twinetverse, or graphTweets more specifically, not only enables visualising interactions between users, it also lets one build and visualise networks of users and the hashtag(s) they use as well as network of hashtags co-mentions. Let’s first look at connecting users to the hashtags they use.
Let’s collect some tweets, since we want to plot relationships between users and hashtags we’ll specify two hashtags: #python and #rstats. This way we’ll be able to see who uses both or either. We’ll also narrow it down to tweets in English to avoid #hashtags we cannot understand.
## Searching for tweets...
## Finished collecting tweets!
Now let’s build a network of hashtags to visualise which user tweets which #hashtag.
Let’s inspect the edges first.
The edges include the
n_tweets variable which is the number tweets the #hashtag is found in. Note that in order to ensure we can always distinguish between a user and a hashtag, hashtag are preceded by the the
# sign. Let’s take a look at the nodes.
Nodes also include the
type which is either set to
Now onto the visualisation. As we did before, we unpack our network, then we prepare the data to fit sigmajs’ expectation, and we color the nodes according to the
type, one colour for #hashtags and another for @users.
In the visualisation we add
sg_neighbours to highlight neighbours of the node clicked, try it.
It is interesting to see that few users actually tweet both hashtags, this wouldn’t have to be in the same tweet so it is somewhat surprising.