Introduction

R has become one of the richest environments for social network analysis. Dozens of packages on CRAN implement everything from basic centrality scores to stochastic actor-oriented models, and most of them interoperate through a small set of shared data structures. This book is an opinionated tour of that ecosystem: what to reach for, when, and why.

What you will learn

You will learn how to represent network data in R, compute the standard descriptive quantities (density, distance, centrality, community structure), produce publication-quality visualizations with ggraph, and fit inferential models such as ERGMs, SAOMs, and relational event models to test hypotheses about how networks form and evolve. The emphasis throughout is on doing: each method is introduced alongside the code needed to run it and the output to expect.

How this book is organized

After this introduction, Network Data and Analysis motivates the network perspective and covers the foundations: nodes, edges, attributes, the common matrix and edge-list representations, and how to import or construct a network in igraph. It is the one chapter the rest of the book assumes you have read.

From there the book splits into four parts:

  • Descriptive Network Analysis covers whole-network and node-level summaries (basic statistics, centrality, cohesive subgroups), together with specialized toolkits for two-mode, signed, and ego networks, and an information-theoretic view through entropy analysis.
  • Network Visualization mainly focuses on ggraph, with chapters on layouts, aesthetic mappings, visual enhancements, and interactive output via g6R.
  • Inferential Network Analysis moves beyond description to statistical modeling: non-parametric tests, random graph models, ERGMs, stochastic actor-oriented models, and relational event models.
  • Tidy Network Analysis revisits descriptive analysis through the lens of tidygraph, which layers tidyverse semantics on top of igraph.

The parts are largely self-contained, so you can read the book linearly or skip to whichever topic is closest to the problem in front of you.

What you won’t learn

This is a book about doing network analysis in R, not a textbook on network theory or graph algorithms. We introduce just enough theory to use each method responsibly and point to canonical references for deeper treatments. We also do not cover network analysis in Python, Gephi, or other GUI-driven tools, and we do not teach base R or the tidyverse from scratch. If you need a primer on either, R for Data Science (2e) is a good companion.

Prerequisites

We assume you are generally numerically literate and have some basic programming experience. If you have never programmed before, Hands-On Programming with R is a useful adjunct to this book.

You need four things to run the code in this book: R, an IDE, a handful of core network packages, and a supporting cast of packages used in individual chapters.

R

Install R from CRAN at https://cloud.r-project.org. A new major version comes out once a year, with two or three minor releases in between. We recommend R 4.5.3 for this book.

IDE

We make no assumption about your development environment. RStudio (https://posit.co/download/rstudio-desktop/) is a popular choice and integrates well with the RStudio addins we occasionally reference, but VS Code, Positron, Emacs, or Vim will all work.

The core packages

Two package families dominate network analysis in R: igraph (Csárdi and Nepusz 2006) and the statnet family (Hunter et al. 2008), which centers on the network data structure and includes sna, ergm, and other modeling packages. Both provide their own graph class and a broadly overlapping set of analytic methods. For descriptive analysis they are largely interchangeable, but each owns a different corner of inferential modeling. igraph is generally faster, since its algorithms are implemented in C, and it has attracted more downstream packages. Figure 1 shows how many CRAN packages depend on, import, or suggest igraph, network, and graph, a package only available via Bioconductor.

Figure 1: Network of CRAN packages that depend on, import, or suggest igraph, network, and graph. The figure was produced with the cranet package.

Because of this imbalance, igraph is the default in the Descriptive Network Analysis and Network Visualization parts. The Inferential Network Analysis part leans on network and statnet, since ergm and its companions are built on top of network. The intergraph package converts between the two representations, and we use it whenever we need to move between ecosystems.

Other packages

Beyond the two core families, the book uses a number of specialized packages. The most important are:

  • ggraph (Pedersen 2025): grammar-of-graphics for network visualization.
  • graphlayouts (Schoch 2023a): advanced layout algorithms for networks.
  • tidygraph (Pedersen 2024): a tidyverse-style interface to igraph.
  • netrankr (Schoch 2022a): a unified framework for centrality indices.
  • signnet (Schoch 2023b): methods for signed networks.
  • backbone (Neal 2022): backbone extraction from weighted and two-mode networks.
  • RSiena (Snijders et al. 2026): stochastic actor-oriented models for longitudinal networks.
  • relevent (Butts 2023): relational event models.
  • egor (Krenz et al. 2025): ego-centered network data.
  • networkdata (Schoch 2022b): a large collection of network datasets used throughout the book.

Each chapter lists the libraries it loads at the top, so you can install packages as you go rather than upfront.

References

Butts, Carter T. 2023. Relevent: Relational Event Models. https://doi.org/10.32614/CRAN.package.relevent.
Csárdi, Gábor, and Tamás Nepusz. 2006. “The Igraph Software Package for Complex Network Research.” InterJournal Complex Systems: 1695. https://igraph.org.
Hunter, David R, Mark S Handcock, Carter T Butts, Steven M Goodreau, and Martina Morris. 2008. “Ergm: A Package to Fit, Simulate and Diagnose Exponential-Family Models for Networks.” Journal of Statistical Software 24 (3): 1–29.
Krenz, Till, Pavel N Krivitsky, Raffaele Vacca, Michal Bojanowski, and Andreas Herz. 2025. Egor: Import and Analyse Ego-Centered Network Data. https://doi.org/10.32614/CRAN.package.egor.
Neal, Zachary P. 2022. “Backbone: An r Package to Extract Network Backbones.” PLOS ONE 17 (5): e0269137. https://doi.org/10.1371/journal.pone.0269137.
Pedersen, Thomas Lin. 2024. Tidygraph: A Tidy API for Graph Manipulation. https://doi.org/10.32614/CRAN.package.tidygraph.
Pedersen, Thomas Lin. 2025. Ggraph: An Implementation of Grammar of Graphics for Graphs and Networks. https://doi.org/10.32614/CRAN.package.ggraph.
Schoch, David. 2022a. “Netrankr: An r Package for Total, Partial, and Probabilistic Rankings in Networks.” Journal of Open Source Software, no. 77: 4563.
Schoch, David. 2022b. Networkdata: Repository of Network Datasets (V0.1.14). https://doi.org/10.5281/zenodo.7189928.
Schoch, David. 2023a. “Graphlayouts: Layout Algorithms for Network Visualizations in r.” Journal of Open Source Software 8 (84): 5238. https://doi.org/10.21105/joss.05238.
Schoch, David. 2023b. “Signnet: An r Package for Analyzing Signed Networks.” Journal of Open Source Software 8 (81): 4987. https://doi.org/10.21105/joss.04987.
Snijders, Tom A B, Ruth M Ripley, Krists Boitmanis, et al. 2026. Siena - Simulation Investigation for Empirical Network Analysis. University of Groningen. https://www.stats.ox.ac.uk/~snijders/siena/.