santoku
santoku

Reputation: 3427

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)

Upvotes: 4

Views: 1678

Answers (1)

lukeA
lukeA

Reputation: 54237

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.

Upvotes: 6

Related Questions