O'Reilly logo

R Data Analysis Cookbook - Second Edition by Kuntal Ganguly

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

Extracting the network as an adjacency matrix from the graph object

Earlier, we created an edge list from a sparse adjacency matrix. Here, we show how to get the sparse adjacency matrix from the graph object that we created in step 4 of the main recipe. In the following, we use type="upper" to get the upper triangular matrix. Other options are lower and both.

> get.adjacency(g,type="upper") 18 x 18 sparse Matrix of class "dgCMatrix" [[ suppressing 18 column names '1', '2', '3' ... ]] 1 . 1 . . . 1 . . . . . 1 . . . . . . 2 . . . . . . 1 . . . . . . . . . . . 3 . . . . . . . . 1 . . . . . . . . . 4 . . . . . . . . 1 . . . . . . . . . 5 . . . . . . . . . . 1 . 1 . . . . . 6 . . . . . . . . . . 1 . . . 1 . . . 7 . . . . . . . . . . 1 . . . 1 ...

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