我有一个图表,其中一个边缘属性是2个顶点之间的相关性。我想根据相关性是正还是负来对我的情节边缘进行不同的着色。 我尝试在plot属性中使用edge.color = c(“red”,“blue”)[E(mygraph)$ correlation> = 0]但我最终只显示前两个边,一个红色,一个蓝色,而没有其他人...... 请参阅此简化示例:
myedges<-data.frame(From=c("item1","item1","item1","item2","item2","item3"),
To=c("item2","item3","item4","item3","item4","item4"),
correlation=c(0.4,0.1,-0.6,-0.3,0.5,0.8))
mygraph<-graph_from_data_frame(myedges, directed=FALSE)
plot(mygraph,
edge.width=E(mygraph)$correlation*50,
edge.color=c("red","blue")[E(mygraph)$correlation>=0])
我做错了什么......?