7

I have a decision tree represented 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?

Mike Lawrence
  • 1,641
  • 5
  • 20
  • 40
  • 1
    haven't used it, but http://cran.r-project.org/web/packages/ggdendro/index.html may be worth looking at. Note, @andrie is the maintainer of the package – Chase Aug 26 '11 at 01:41
  • no luck, ggdendro plots trees resulting from fitting algorithms like hclust, kmeans, etc. I don't see a simple way to plot a tree from a list. – Mike Lawrence Aug 26 '11 at 02:06
  • You might a look at @Iselzer's answer to this question: http://stackoverflow.com/questions/6673162/reproducing-lattice-dendrogram-graph-with-ggplot2 – Iterator Aug 27 '11 at 22:17

1 Answers1

1

I don't think there's an immediate way, since packages for plotting trees would want a specific data structure for the tree which would unlikely match your list. So likely you'll need to convert your list into another form.

I would look at the igraph package. I'd start with the graph() function; if you could convert your list (describing a tree) to a graph, the igraph package would help you to plot it.

Karl
  • 2,009
  • 15
  • 14