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)
source
share