Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plot a tree diagram from a list in R

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?

like image 745
Mike Lawrence Avatar asked Aug 26 '11 01:08

Mike Lawrence


1 Answers

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.

like image 99
Karl Avatar answered Sep 24 '22 20:09

Karl