Learn R Programming

⚠️There's a newer version (1.2.0) of this package.Take me there.

Badges

Master

Dev

data.tree

An R package to manage hierarchical data and tree structures

Hierarchical data is ubiquitous in statistics and programming (XML, search trees, family trees, classification, file system, etc.). However, no general-use tree data structure is available in R. Where tabular data has data.frame, hierarchical data is often modeled in lists of lists or similar makeshifts. These structures are often difficult to manage. This is where the data.tree package steps in. It lets you build trees of hierarchical data for various uses: to print, to generate breakdowns, to integrate with html widgets, to rapid prototype search algorithms, to test out new classification ideas, and much more.

The package provides functionality to convert from and to various formats such as data.frames, list of lists, dendrograms, ape phylo, igraph, JSON, YAML, and more.

NOTE:

The latest from github dev branch may have some breaking changes compared to CRAN. See NEWS for details.

Conventions:

Coding Conventions: Google Style Guide, see https://google-styleguide.googlecode.com/svn/trunk/Rguide.xml

Versioning Conventions: SemanticVersioning. See http://semver.org/ for details

Branching Conventions: GitFlow. See https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow

Pull Requests: Very welcome. Please branch from the dev branch if possible.

Copy Link

Version

Install

install.packages('data.tree')

Monthly Downloads

30,177

Version

0.3.2

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Christoph Glur

Last Published

August 25th, 2025

Functions in data.tree (0.3.2)

as.igraph.Node

Convert a data.tree structure to an igraph network
Aggregate

Aggregate child values of a Node, standalone or in traversal.
AreNamesUnique

Test whether all node names are unique.
as.list.Node

Convert a data.tree structure to a list-of-list structure
as.Node

Convert an object to a data.tree data structure
as.dendrogram.Node

Convert a Node to a dendrogram
as.Node.dendrogram

Convert a dendrogram to a data.tree Node
as.Node.data.frame

Convert a data.frame to a data.tree structure
as.data.frame.Node

Convert a data.tree structure to a data.frame
acme

Sample Data: A Simple Company with Departments
data.tree

data.tree: Hierarchical Data Structures
as.phylo.Node

Convert a Node to a phylo object from the ape package.
Clone

Clone a tree (creates a deep copy)
Cumulate

Cumulate values among siblings
averageBranchingFactor

Calculate the average number of branches each non-leaf has
CreateRegularTree

Create a tree for demo and testing
CreateRandomTree

Create a tree for demo and testing
as.Node.phylo

Convert a phylo object from the ape package to a Node
as.Node.list

Convert a nested list structure to a data.tree structure
isLeaf

Check if a Node is a leaf
DefaultPlotHeight

Calculates the height of a Node given the height of the root.
Find

Find a node by name in the (sub-)tree
GetPhyloNr

Determine the number a Node has after conversion to a phylo object
isNotLeaf

Check if a Node is not a leaf
FormatFixedDecimal

Format a Number as a Decimal
Do

Executes a function on a set of nodes
FormatPercent

Format a Number as a Percentage
isRoot

Check if a Node is the root
Revert

Reverts the sort order of a Node's children.
Set

Traverse a Tree and Assign Values
NODE_RESERVED_NAMES_CONST

Names that are reserved by the Node class.
isNotRoot

Check if a Node is not a root
Prune

Prunes a tree.
Node

Create a data.tree Structure With Nodes
print.Node

Print a Node in a human-readable fashion.
mushroom

Sample Data: Data Used by the ID3 Vignette
Traverse

Traverse a tree or a sub-tree
Sort

Sort children of a Node or an entire data.tree structure
plot.Node

Plot a graph, or get a graphviz dot representation of the tree
ToNewick

Write a data.tree structure to Newick notation
Climb

Find a Node by provided criteria.
Get

Traverse a Tree and Collect Values
SetFormat

Set a formatter function on a specific node
GetAttribute

Get an attribute from a Node.