我正在尝试使用forceNetwork
,但是链接指向左上角,并且链接不符合预期。
library(tidyverse)
library(networkD3)
nodes <- data.frame(name=c("H2o","H2O Driverless AI ","DAI","This is a Mechanized Operations Tracking System","H2O.ai","H2O","H2O is open-source software for Big Data analysis"),group = 1)
nodes <- nodes %>% rowid_to_column("id")
nodes_d3 <- mutate(nodes, id = id - 1)
links <- data.frame(source=c(0,1,2,0,4,5),target=c(1,2,3,4,5,6))
forceNetwork(Links = links, Nodes = nodes_d3, Source = "source", Target = "target",
NodeID = "id",Group = "group", opacity = 0.8,arrows = TRUE, zoom = TRUE)
预计将h20作为节点0,然后将其连接到“ H2O无人驾驶AI”和H2O.ai。然后,H2O无人驾驶AI> DAI。然后DAI>这是一个机械化的作业跟踪系统。 H2O.ai> H2O。 H2O> H2O是用于大数据分析的开源软件
如果我做错了,请纠正。
答案 0 :(得分:0)
鉴于您的数据,您可能应该使用NodeID = "name"
更新:
您还必须设置Value
参数。这是一个可重现的示例...
library(tidyverse)
library(networkD3)
nodes <- data.frame(name=c("H2o","H2O Driverless AI ","DAI","This is a Mechanized Operations Tracking System","H2O.ai","H2O","H2O is open-source software for Big Data analysis"),group = 1)
nodes <- nodes %>% rowid_to_column("id")
nodes_d3 <- mutate(nodes, id = id - 1)
links <- data.frame(source=c(0,1,2,0,4,5),target=c(1,2,3,4,5,6), value = 1)
forceNetwork(Links = links, Nodes = nodes_d3, Source = "source", Target = "target",
Value = "value", NodeID = "name", Group = "group", opacity = 0.8,arrows = FALSE, zoom = TRUE)