R Language Network analysis with the igraph package Simple Directed and Non-directed Network Graphing

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

The igraph package for R is a wonderful tool that can be used to model networks, both real and virtual, with simplicity. This example is meant to demonstrate how to create two simple network graphs using the igraph package within R v.3.2.3.

Non-Directed Network

The network is created with this piece of code:

g<-graph.formula(Node1-Node2, Node1-Node3, Node4-Node1)
plot(g)

Valid XHTML

Directed Network

dg<-graph.formula(Tom-+Mary, Tom-+Bill, Tom-+Sam, Sue+-Mary, Bill-+Sue)
plot(dg)

This code will then generate a network with arrows:

Valid XHTML

Code example of how to make a double sided arrow:

dg<-graph.formula(Tom-+Mary, Tom-+Bill, Tom-+Sam, Sue+-Mary, Bill++Sue)
plot(dg)

Valid XHTML



Got any R Language Question?