I am trying to create a simple forceNetwork
, but the plot won't render. I keep getting the following warning:
Warning message: It looks like Source/Target is not zero-indexed. This is required in JavaScript and so your plot may not render.
How do I fix this? Note that simpleNetwork
works fine so the problem seems to be in how I am specifying my data.
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)