Diagrammer cannot create nodes in R

I currently have version R 3.2.2 with package DiagrammeRR. I get these two errors when trying to run the following code:

library(DiagrammeR)
nodes <- create_nodes(nodes = seq(uniquenodes), 
                      type = "number", 
                      label = uniquenodes)

Error: could not find function "create_nodes"

edges <- create_edges(from = match(df$col1, uniquenodes), 
                      to = match(df$col2,uniquenodes), 
                      rel = "related")

Error: could not find function "create_edges"

+4
source share
2 answers

The code below should be compatible with DiagrammeR0.9.0. The graph appears to be different from the species generated in DiagrammeR creates "incorrect" diagram in R . I have not played with render_graphin 0.9.0, so I'm still not sure how to get an earlier look.

df <- data.frame(col1 = c("Cat", "Dog", "Bird"),
                 col2 = c("Feline", "Canis", "Avis"),
                 stringsAsFactors = FALSE)
uniquenodes <- unique(c(df$col1, df$col2))

uniquenodes

library(DiagrammeR)

nodes <- create_node_df(n=length(uniquenodes), 
                        type="number", 
                        label=uniquenodes)
edges <- create_edge_df(from=match(df$col1, uniquenodes), 
                        to=match(df$col2, uniquenodes), 
                        rel="related")
g <- create_graph(nodes_df=nodes, 
                  edges_df=edges)
render_graph(g)
+4
source

render_graph 0.9.0, , .

attr_theme create_graph, "default". NULL , set_global_graph_attributes, magrittr:%>%, : fooobar.com/questions/1669081/...

+1

Source: https://habr.com/ru/post/1669078/


All Articles