R Programming/Network Analysis

R Programming/analysis

Introduction
We mainly use the following packages to demonstrate network analysis in R: statnet, sna, igraph. They are however not representing a complete list. See Task view of gR, graphical models in R for a complete list.

Creating graphs from data
First load the igraph package then you can choose your preferred format. Below are examples of data provided as edge list and as adjacency matrix.

Creating graph from an edge list
An edge list is formed by a two-column matrix, with each row defining one edge. An edge is drawn from each element in the first column to the corresponding element in the second one. Use the  function to import your data.

Creating graph from an adjacency matrix
An adjacency matrix is a n × n matrix containing n vertices and where each entry aij represents the number of edges from vertex i to vertex j. To import your adjacency matrix, use the  function.