data.tree 0.3 ‘Apple Tree’ on CRAN: Now with tree plot! 6

In Celtic mythology, the apple tree is a symbol for fruitfulness. May data.tree blossom and fructify … and generate that perfect tree plot for us!

The hottest feature of the new release are tree plots: Thanks to the DiagrammeR package, we can now generate beautiful plots in html format. You can include them in RMarkdown documents, web pages, shiny apps, and more. And they may contain interactive tooltips and more.

In case you don’t know what data.tree is: It’s a generic data.structure in R, letting you model and work with hierarchic data with ease. There are two vignettes, walking you through the possibilities offered by the package:

data.tree introduction vignette

sample applications using data.tree

data.tree is useful when converting hierarchic data structures from and to R (e.g. JSON, YAML), for recursive programming algorithms, and much more. For example, the AHP package has been developed with data.tree. Check out the AHP sample application to learn more.

To install the package, simply type the following in R:

To get started with tree data structures, you may want to look at acme, the package sample data.tree structure.

This will print the tree to the console:

To generate a (non-styled) tree plot of the acme sample data, do the following:

This will display a basic tree plot of our sample tree. It looks something like this:

acme tree plot



With a few directives, we can style this to our needs:

acme tree plot with style


Styling is very flexible, yet it takes advantage of the fact that data.tree structures are strictly hierarchical. For example, styling attributes are inherited from parents to children (except inheritance is explicitly set to FALSE).

The release contains also a few fixes and other improvements. See here for the release notes. And if you have questions or want to report a bug, then please do so directly on github. And if you want to get informed about solved issues, new releases, etc., please star the project on github.

So, to frame this post appropriately with yet another apple analogy, let’s close with the following noticeable fact: In the Ulster Cycle, the soul of Cú Roí was confined in an apple that lay in the stomach of a salmon which appeared once every seven years. Not that I know what the Ulster Cycle is, or who in the world Cú Roí was. But it makes a nice story, as we all do hope that the next data.tree release will appear earlier than that!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

6 thoughts on “data.tree 0.3 ‘Apple Tree’ on CRAN: Now with tree plot!

  • QL

    Why error with plot(acme)?

    > library(data.tree)
    > acme accounting software standards research newProductLine newLabs it outsource agile goToR
    > print(acme)
    1 Acme Inc.
    2 ¦–Accounting
    3 ¦ ¦–New Software
    4 ¦ °–New Accounting Standards
    5 ¦–Research
    6 ¦ ¦–New Product Line
    7 ¦ °–New Labs
    8 °–IT
    9 ¦–Outsource
    10 ¦–Go agile
    11 °–Switch to R
    > plot(acme)
    Error in as.double(y) :
    cannot coerce type ‘environment’ to vector of type ‘double’

  • Tom

    Hi Christoph,

    I’ve been playing around with your data.tree package and think it’s excellent. What would be the best way to apply this to time series data? I have a data frame with 10 years of data and am trying to find a way to create the bottom level time series nodes of a hierarchy.