2
我试图为节点6和7着色,而不管从对象'd'中选择的任何字母。igraph中的颜色特定节点
g <- graph_from_literal(1:2:3:4:5 -- 6:7)
# Rename (sum up all the vertices)
d <- c("a", "b", "c", "d", "e", "f", "g","h", "i", "j")
V(g)$name <- sample(d, 7, replace=TRUE)
colours <- c("red")
V(g)$color <- ifelse(V(g)$name == c('a','e'), "white", colours)
plot.igraph(g, layout=layout_with_dh, vertex.label=V(g)$name,
vertex.size=35,
vertex.color=V(g)$color, #colors.r
vertex.label.cex=0.7,
)
我试过了上面的ifelse(),但它们似乎没有取数值。我希望得到一些帮助。
我想要的是节点6是例如白色和7是例如绿色,其他节点是红色的。
谢谢!
谢谢你这么多。 – Sam