我试图找出 forceNetwork() 中节点和链接数据帧的确切要求,因为我的网络显示彩色可移动点而没有任何边缘连接它们,我不知道为什么。据我所知,要求是:
节点数据框必须具有:
链接数据框必须具有:
> head(links)
source target value
1 11170 7 1
2 2840 2 1
3 32595 2 1
4 45410 8 1
5 52720 12 1
6 61720 6 1
> head(nodes)
nodeID group
1 11170 2
2 2840 1
3 32595 2
4 45410 3
5 52720 1
6 61720 2
> head(E(g))
Edge sequence:
[1] 7 -- 11170
[2] 2 -- 2840
[3] 2 -- 32595
[4] 8 -- 45410
[5] 12 -- 52720
[6] 6 -- 61720
> head(V(g))
Vertex sequence:
[1] "11170" "2840" "32595" "45410" "52720" "61720"
> typeof(nodes$nodeID[1])
[1] "integer"
> typeof(links$source[1])
[1] "integer"
> dim(links)
[1] 121 3
> dim(nodes)
[1] 135 2
> forceNetwork(Links = links, Nodes = nodes,Source = "source", Target = "target", NodeID = "nodeID",Group = "group", opacity = 0.8, colourScale = "d3.scale.category10()")