4

オブジェクト「d」から選択された文字に関係なく、ノード 6 と 7 に色を付けようとしています。

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 がたとえば緑で、残りのノードが赤であることです。

ありがとうございました!

4

2 に答える 2