问题
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