'How to get igraph to use variables as vertices?
I feel like this is a very stupid question, but here we are.
I'm using igraph for the first time for a network analysis, and the resulting graph has values as vertices instead of the variable names... what is happening?
Thank you.
data <- read.spss("data.sav", use.value.labels = TRUE, to.data.frame=TRUE, add.undeclared.levels = c("no"))
g <- graph_from_data_frame(data, directed = FALSE)
plot.igraph(g)
Solution 1:[1]
You'd like the plot to print some feature of the vertices rather than arbitrary numbers. You can specify a vertex.label as shown below.
plot.igraph(g, vertex.label = get.vertex.attribute(g, "variable"))
Here "variable" is the name of an attribute you would like to print on each vertex.
You can learn more about plotting in the help here: ?igraph.plotting (there's a link to this help page buried in ?plot.igraph)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ari Anisfeld |
