rnetwork-programmingedgesarrowsvisnetwork

Arrows in a visNetwork plot in R


I'm creating a network using the visNetwork library in R. My network is directed and hence I want arrows in my network. But I can't seem to get it, even after adding it to the edges data frame

I tried adding it to the data frame as follows:

edges = data.frame(from = dat1$target, to = dat2$source, arrows <- "to", arrows.to.type="arrow")

I want the edges to have a pointy arrow, pointing towards the "end" or "to" of the edges What am I missing/doing wrong?


Solution

  • Instead of/Along with writing '(arrows <- "to", arrows.to.type="arrow")' in the edges data frame, try this while calling visNetwork():

    visNetwork(nodes, edges) %>%
      visEdges(arrows ="to")
    

    This should do it :)