Learn R Programming

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

CRAN:

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 base 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, plot and visualize, to generate breakdowns, to integrate with html widgets, to rapid prototype search algorithms, to test out new classification ideas, and much more.

Tree structures can be created programmatically, or by conversion. The package provides functionality to convert from and to various formats such as data.frames, list of lists, dendrograms, partykit, ape phylo, igraph, JSON, YAML, and more.

Learn More

To get started, you might want to read the introduction vignette. There is also a vignette containing some examples and applications.

The manual is here

Finally, you'll find more examples and background information on my blog.

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.github.io/styleguide/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.

Copy Link

Version

Install

install.packages('data.tree')

Monthly Downloads

24,634

Version

0.7.0

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Christoph Glur

Last Published

November 12th, 2023

Functions in data.tree (0.7.0)

as.list.Node

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

Convert a dendrogram to a data.tree Node
Aggregate

Aggregate child values of a Node, recursively.
acme

Sample Data: A Simple Company with Departments
as.Node.data.frame

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

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

Convert a data.tree structure to an igraph network
as.Node.BinaryTree

Convert a a SplitNode from the party package to a data.tree structure.
as.phylo.Node

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

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

Checks whether name is a reserved word, as defined in NODE_RESERVED_NAMES_CONST.
Clone

Clone a tree (creates a deep copy)
as.Node.list

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

Climb a tree from parent to children, by provided criteria.
as.Node

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

Convert a a party from the partykit package to a data.tree structure.
as.Node.phylo

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

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

Prunes a tree.
Revert

Reverts the sort order of a Node's children.
as.dendrogram.Node

Convert a Node to a dendrogram
Distance

Find the distance between two nodes of the same tree
NODE_RESERVED_NAMES_CONST

Names that are reserved by the Node class.
Do

Executes a function on a set of nodes
Sort

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

Print a Node in a human-readable fashion.
CreateRandomTree

Create a tree for demo and testing
plot.Node

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

Create a tree for demo and testing
Cumulate

Cumulate values among siblings
isLeaf

Check if a Node is a leaf
Set

Traverse a Tree and Assign Values
SetFormat

Set a formatter function on a specific node
isNotLeaf

Check if a Node is not a leaf
GetAttribute

Get an attribute from a Node.
FormatFixedDecimal

Format a Number as a Decimal
FindNode

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

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

Write a data.tree structure to Newick notation
Traverse

Traverse a tree or a sub-tree
FormatPercent

Format a Number as a Percentage
Get

Traverse a Tree and Collect Values
isRoot

Check if a Node is the root
DefaultPlotHeight

Calculates the height of a Node given the height of the root.
data.tree

data.tree: Hierarchical Data Structures
isNotRoot

Check if a Node is not a root
mushroom

Sample Data: Data Used by the ID3 Vignette
Navigate

Navigate to another node by relative path.
Node

Create a data.tree Structure With Nodes