why doesn't this visNetwork in R show edge

瘦欲@ 提交于 2019-12-14 01:34:07

问题


I'm exploring visNetwork and can't figure out why this one doesn't show edge

library(visNetwork)
nodes=data.frame(node=c('m1','m2','n1','n2'))
a=data.frame(x=c('n1','n2'),y=c('m1','m2'))
links=a%>% group_by(x,y)%>%tally()
visNetwork(nodes, links)

回答1:


From ?visNetwork:

nodes: data.frame with nodes informations. Needed at least column "id".
edges: data.frame with edges informations. Needed at least columns "from" and "to".

So

visNetwork(
  setNames(nodes, "id"),
  setNames(links, c("from", "to", "foo"))
) 

will work.



来源:https://stackoverflow.com/questions/38169336/why-doesnt-this-visnetwork-in-r-show-edge

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!