O'Reilly logo

R Data Analysis Cookbook by Shanthi Viswanathan, Viswa Viswanathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Computing important network metrics

This recipe covers the methods used to compute some of the common metrics used on social networks.

Getting ready

If you have not yet installed the igraph package, do it now. If you worked through the earlier recipes in this chapter, you should have the data files directed-graph.Rdata, undirected-graph.Rdata, and bipartite-graph.Rdata and should ensure that they are in your R working directory. If not, you should download these data files and place them in your R working directory.

How to do it...

To compute important network metrics, follow these steps:

  1. Load the data files:
    > load("undirected-graph.Rdata")
    > load("directed-graph.Rdata")
    > load("bipartite-graph.Rdata")
  2. The degree centrality can be measured as follows: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required