The following Dodona exercises provide an introduction to Social Network Analysis in R. For a more detailed explanation it is possible to consult the book User’s Guide to Network Analysis in R.

To plot networks in R, as seen in the lecture slides, two main network packages are used, namely the statnet suite of packages (network, SNA packages) and the igraph package. In the following exercises the statnet package is used unless otherwise stated.

Before starting the exercises, the necessary packages need to be installed and loaded. The following code block accomplishes this:

if (!require(statnet)){
  install.packages("statnet", 
                    repos="https://cran.rstudio.com/",
                    quiet=TRUE)}

library(statnet)

Since it is time-consuming to always write down this if-else statement to install and load packages, the pacman package offers several convenience functions to instantly and quietly load packages. The function p_load performs the above functions in the background.

p_load(devtools)

During the exercises, a mix of examples from the book User’s Guide to Network Analysis in R and own examples is used. To make sure that you have the data sets from the book available, load the Github repository from the book as follows. Note that we will again be using the functionalities of the pacman package.

p_load_current_gh("DougLuke/UserNetR")