I am trying to plot a decision tree with igraph. However, I do not know how to create a data structure that will allow to plot a decision tree with igraph.
Any tips?
I am trying to plot a decision tree with igraph. However, I do not know how to create a data structure that will allow to plot a decision tree with igraph.
Any tips?
This an example :
library(data.tree)
library(igraph)
acme <- Node$new("Acme Inc.")
accounting <- acme$AddChild("Accounting")
software <- accounting$AddChild("New Software")
standards <- accounting$AddChild("New Accounting Standards")
research <- acme$AddChild("Research")
newProductLine <- research$AddChild("New Product Line")
newLabs <- research$AddChild("New Labs")
it <- acme$AddChild("IT")
outsource <- it$AddChild("Outsource")
agile <- it$AddChild("Go agile")
goToR <- it$AddChild("Switch to R")
print(acme)
plot(as.igraph(acme, directed = TRUE, direction = "climb"))
Source : https://cran.r-project.org/web/packages/data.tree/vignettes/data.tree.html