问题
The relationship is expressed as a matrix x
like this:
John Jack Mary Wendy
John 0 2 1 1
Jack 2 0 1 0
Mary 1 1 0 1
Wendy 1 0 1 0
The entries refer to the number of connections they have. Could anyone show me how to plot it as a network in R? Thanks!
回答1:
This is known as an adjacency matrix.
There is some information in the R FAQ on plotting social networks expressed as matrices:
Plotting social network data can be easily done with the igraph package in R. [...] In order for the igraph package to recognize this table as a network, we can first convert it to a matrix. Then, if we wish to calculate graph-related statistics on it (betweenness, closeness, degree), we can use the matrix to create a graph object.
The FAQ gives some examples, resulting in sociogram diagrams, for example:
The igraph
library itself is documented here - it can produce much more complex examples - see the screenshots page and the example below:
来源:https://stackoverflow.com/questions/13203778/how-to-plot-relationships-in-r