I have network data (cellphone data) from participants in a study, and I'm trying to make a network with this data, but since the edgelist is made up of just participants connecting with other random people, when I use attributes from the participants to add color, etc. to the network visualization, it doesn't apply correctly because it thinks it should apply to all nodes (since the left-hand column is made up of participants, and the right hand is all the random people they called, the random people in the right-hand column are taking on the same attributes as the participant). I was able to find a workaround for coloring the nodes based on being a participant or not using another person's question (code below), but I can't figure out how to use the attributes (e.g. average call length, number of calls) to change parts of the visualization due to the way the edgelist is set up. Is there another way to do this??
code workaround for coloring the nodes based on being a participant:
plot(
BE_1,
vertex.label=NA,
vertex.color=ifelse(degree(BE_1, mode = "out")>0, "red", "black"),
vertex.size=ifelse(degree(BE_1, mode = "out")>0, 15, 4),
edge.arrow.size=.1
)
I've tried vertex.size= based on different attributes, but that hasn't worked, so here I've just set up the non-participants to be smaller.
From your description your edgelist looks something like this:
Create a data set that describes the participants by aggregating the edgelist.
nodes_randos contains the names/ids of the non-participants. We need this because
igraphrequires the nodes dataset to contain all nodes.Create
nodesdataframeCreate
igraphobjectSome igraph plotting examples.
ggraphplotting example.ggraph()takes care of scaling the node size.