Book Image

R Data Visualization Cookbook

Book Image

R Data Visualization Cookbook

Overview of this book

Table of Contents (17 chapters)
R Data Visualization Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Constructing network plots


One of the first visualizations that introduced me to network plots was Visualizing Friendships. Network plots are not just limited to social networks but are observed in finance to study the linkages between Markets; they have been implemented in medicine to study the spread of viruses; and they have also been used to study social dynamics of groups, such as a network of friends. Network is an actively researched field and lots of books and articles have been published on it.

In this recipe, we will study the basics of creating a network plot using a random dataset.

Getting ready

We will construct a network plot using the igraph package in R.

How to do it…

To construct a network plot, we will install the igraph package and also load it in our active R session by typing the following lines of code:

install.packages("igraph")
library(igraph)

Next, we generate fake data and import it in R using the read.csv() function:

net = read.csv("network.csv", sep = ",", header = TRUE...