我正在尝试创建一个简单的forceNetwork
,但情节不会呈现。我不断收到以下警告:
Warning message: It looks like Source/Target is not zero-indexed. This is required in JavaScript and so your plot may not render.
我该如何解决?请注意,它simpleNetwork
工作正常,所以问题似乎在于我如何指定我的数据。
library(igraph)
library(networkD3)
set.seed(42)
temp<-data.frame(source=c(1,2,3,4),target=c(2,3,4,4))#csv[1:500,]
links<-data.frame(source=temp$source,target=temp$target)
g<-graph.data.frame(cbind(temp$source,temp$target), directed=T)
nodes<-data.frame(name=1:length(V(g)),group=1)
forceNetwork(Links=links,Nodes = nodes,
Source = 'source', Target = 'target',
NodeID = 'name', Group = 'group')
simpleNetwork(temp)