I have several networks that I would like to use the assortativity function on. The problem is, I am only interested if nodes of one particular label tend to cluster together, and I don't want nodes of other labels to interfere. Is there a way to isolate the assortativity index so that it only takes the nodes with one label, rather than all labels?
Or, is it best if I use the numerical version and relabel my nodes of interest to "1", and all other node labels to "0"?
Here is a small example
links <- data.frame("From" = c(1, 1, 2,
2, 3, 9,
4, 5, 2),
"To" = c(3, 2, 1,
5, 9, 5,
1, 9, 1))
links
nodes <- data.frame("Food" = c(1, 2, 3, 4, 5, 9),
"Type" = c("soup", "bread", "pickles",
"vegtables", "drink", "potato side")
)
nodes
nw <- graph_from_data_frame(d = links,
vertices = nodes,
directed = T)
assortativity.nominal(nw,
V(nw)$Type,
directed = T)
How would I calculate the tendency of potato sides to be with each other?