Build a tree diagram from a list in R

I have a decision tree presented as a list in R:

tree = list( "Bin type" = list( "no bin" = list( "SOA linearity" = list( "linear" = list("Linear MEM") , "non-linear" = list("GAMM") ) ) , "bin" = list( "SOA type" = list( "SOA as categorical" = list( "Tool" = list( "ANOVA" , "MEM" ) ) , "SOA as continuous" = list( "SOA linearity" = list( "linear" = list( "Tool" = list( "ANOVA" , "MEM" ) ) , "non-linear" = list("GAMM") ) ) ) ) ) ) 

Is there a quick way to visualize this as a tree diagram?

+7
source share
1 answer

I don’t think there is an immediate way, because packages for building trees will require a certain data structure for the tree, which would hardly fit your list. You will probably need to convert your list to another form.

I would look at igraph . I would start with the graph() function; if you can convert your list (describing a tree) into a graph, the igraph package will help you build it.

+1
source

All Articles