R networkD3 package: node coloring in simpleNetwork()

后端 未结 4 429
甜味超标
甜味超标 2020-12-03 06:00

The networkD3 package (see here and here) allows a user to create simple interactive networks:

# Load package
library(networkD3)

# Create fake          


        
4条回答
  •  生来不讨喜
    2020-12-03 06:22

    You could do a similar thing as in the linked post, but here is an example using the visNetwork package. This package interfaces with vis.js, and makes really nice interactive graphs.

    library(visNetwork)
    id <- unique(c(src, target))                                  # node ids
    nodes <- data.frame(id, group=+(id %in% src),                 # add a grouping for src/target
      label=id, title=sprintf('

    Node %s

    ', id)) # add some labels g <- visNetwork(nodes=nodes, edges=networkData, width="75%") # make graph visExport(visHierarchicalLayout(g)) # make it tree-like

提交回复
热议问题