Chapter 3 Packages

Below are the packages that make up in the twinetverse as well as some explanation of what they bring to visualising Twitter interactions. Though considered a package the ’verse itself only comes with two functions, all the other functions we’ll use in this book are part of the packages detailed below.

3.1 rtweet

If we are going to visualise Twitter interactions we are going to need data, namely tweets. The rtweet package (Kearney 2018) wraps the Twitter API, thereby giving R users easy access to tweets.

From the official website:

[rtweet is an] R client for accessing Twitter’s REST and stream APIs

3.1.1 Usage

rtweet fills the very first step in visualising Twitter interactions, collecting the necessary data.

Note that the package lets you do much more than simply downloading tweets, however, within the twinetverse, this is its main function.

3.2 graphTweets

3.2.1 Rationale

The graphTweets package (Coene 2018a) lets you extract nodes and edges from tweets collected with rtweet. The package is fairly straighforward as it inludes just a few functions. However, it still enables you to build relatively complex graphs.

The package revolves around two core functions which respectively allow you to build data.frames of edges and nodes. These edges and nodes (also referred to as vertices) together map Twitter conversations by linking the sender of a tweet to the user(s) he or she @tags.

Though the package also allows returning igraph objects (file. (2018)) this is not necessary in the twinetverse, and therefore not demonstrated in this book. More information is available on the package’s official website.

3.2.2 Usage

All functions of the package start with gt_. graphTweets fills the second step in visualising Twitter interactions, building the graphs from the collected data.

3.3 sigmajs

The sigmajs package (Coene 2018b) is a powerful library to visualise the networks we have built using graphTweets. The package, like graphTweets, is pipe-friendly (%>%), therefore making it easy to go from building a graph to visualising it. It can also easily represent dynamic networks, something otherwise not evident in R.

Features:

  • Highly interactive
  • Crosstalk integrated
  • Includes Shiny proxies
  • Events in Shiny
  • Buttons to trigger interactions.
  • and more.

3.3.1 Usage

All functions of the package start with sg_. sigmajs is the final piece of the puzzle, visualising the graphs we have built.

References

Kearney, Michael W. 2018. Rtweet: Collecting Twitter Data. https://CRAN.R-project.org/package=rtweet.

Coene, John. 2018a. GraphTweets: Visualise Twitter Interactions. http://graphTweets.john-coene.com.

file., See AUTHORS. 2018. Igraph: Network Analysis and Visualization. https://CRAN.R-project.org/package=igraph.

Coene, John. 2018b. Sigmajs: Interface to ’Sigma.js’ Graph Visualization Library. http://sigmajs.john-coene.com/.