Tag Archives: sociomatrix

Extracting adjacency matrices with valued edges

This may seem obvious to an expert statnet user, but it took me a bit of careful reading of Carter's paper and some trial and error to figure it out. We are using the frequency of behaviors based on ethological observations as edge weights and would like to be able to extract a matrix of the edge weights.

R:
  1. set.seed(123)
  2. ## generate a network with 21 nodes and 50 edges.
  3. ## some edges are either self-loops or redundant
  4. ## just a quick and dirty way to get an example network object
  5.  
  6. n1 <- round(1+20*runif(50))
  7. n2 <- round(1+20*runif(50))
  8. n3 <- rpois(50,3)
  9. eee <- cbind(n1,n2)[order(n1),]
  10. net <- network(eee,directed=FALSE)
  11. set.edge.attribute(net,"meaningful.measure",n3)
  12. as.matrix(net,attrname="meaningful.measure")

This last command returns a 50x50 matrix of the edge weights.