Social networks in R

I need help creating a social network object called which reflects the proximity network and which has the names of the actors appropriately reflected in the vertex.names node attribute. Output the adjacency matrix for this network object.

Currently, I have done the following:

coworking.adjacency.matrix <- matrix(c( 0, 1, 1, 0, 0, 0, 1, 0, 1 , 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0,  1,   0, 0, 0, 1, 1, 0, 0, 0), nrow = 6, byrow = TRUE, dimnames = list(c("Abigail", "Francis", "Christy", "Bob", "Daniel", "Ethan"), c("Abigail", "Francis", "Christy", "Bob", "Daniel", "Ethan")))

More of a reproducible example, called a reprex would be helpful in attracting more answers. I'm going to assume that you are using the network library, and not sna or igraph.

coworking.adjacency.matrix is defined as a matrix object, labelled with the same given names as columns and rows, with 1 indicating an edge and 0 indicating no edge.

The first thing you need to do is to create a network::network object, which has the following signature

network(x, vertex.attr=NULL, vertex.attrnames=NULL, directed=TRUE,
hyper=FALSE, loops=FALSE, multiple=FALSE, bipartite = FALSE, ...)

Where x is your coworking.adjacency.matrix.

n <- network(coworking.adjacency.matrix)

gives you a network object, which contains the vertex name attributes in n$val, and


will return the names of the vertices.

[1] "Abigail" "Francis" "Christy" "Bob"     "Daniel"  "Ethan"  

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.