我想创建一个漂亮的图形来说明我的一些数据。
我已经创建了图形,但是我想向节点添加一些计算的文本。我该怎么做呢。
这是我的图表,但是如何/在哪里添加在R中计算出的字段?:
library(magrittr)
library(DiagrammeR)
# Create a simple NDF
nodes <-
create_nodes(nodes = c("Index", "Surveillance", "Intervention", "Lost to Follow-up"))
# Create a simple EDF
edges <-
create_edges(from = c("Index", "Surveillance", "Index", "Surveillance","Intervention","Surveillance","Intervention"),
to = c("Surveillance", "Intervention", "Lost to Follow-up", "Lost to Follow-up","Intervention","Surveillance","Lost to Follow-up"),
)
graph <-
create_graph(
nodes_df = nodes,
edges_df = edges,
graph_attrs = "layout = twopi",
node_attrs = "fontname = Helvetica",
edge_attrs = "color = gray20"
)
# View the graph
render_graph(graph,output = "visNetwork")
require(visNetwork, quietly = TRUE)
nb = "Information here"
nodes <- data.frame(id = 1:5, group = c(rep("A", 2), rep("B", 3)),
title = paste("<p>", 1:5,"<br>",nb, sep = ""), stringsAsFactors = FALSE)
edges <- data.frame(from = c(2,5,3,3), to = c(1,2,4,2))
### USE
visNetwork(nodes, edges, width = "100%") %>% visOptions(highlightNearest = list(enabled =TRUE,algorithm="hierarchical"))
当您在节点上传递鼠标时,您将看到您的信息。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句