Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why doesn't this visNetwork in R show edge

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)
like image 683
santoku Avatar asked Oct 11 '25 14:10

santoku


1 Answers

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.

like image 149
lukeA Avatar answered Oct 14 '25 07:10

lukeA