2016-06-26 7 views
1

Ich möchte ein nettes Diagramm erstellen, das einige meiner Daten veranschaulicht.So fügen Sie Text zu einem Diagramm in diagrameR

Ich habe das Diagramm erstellt, aber ich möchte etwas berechneten Text zum Knoten hinzufügen. Wie mache ich das.

Das ist mein Graph ist aber wie/wo füge ich ein Feld I in R berechnet haben ?:

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") 

Antwort

2
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")) 

Sie Ihre Daten sehen, wenn Sie mit der Maus auf Ihren Knoten passieren.

Verwandte Themen