Learn R Programming

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

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 has 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

11,991

Version

0.2.4

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Christoph Glur

Last Published

November 12th, 2023

Functions in data.tree (0.2.4)

as.list.Node

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

Convert a phylo object from the ape package to a Node
SetFormat

Set a formatter function on a specific node
Climb

Find a Node by provided criteria.
print.Node

Print a Node in a human-readable fashion.
AreNamesUnique

Test whether all node names are unique.
GetPhyloNr

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

Names that are reserved by the Node class.
CreateRandomTree

Create a tree for demo and testing
FormatPercent

Format a Number as a Percentage
Clone

Clone a tree (creates a deep copy)
Prune

Prunes a tree. This function has side-effects, it modifies your data.tree structure!
as.data.frame.Node

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

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

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

Convert a Node to a dendrogram
ToNewick

Write a data.tree structure to Newick notation
as.Node.list

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

Sample Data: Data Used by the ID3 Vignette
Sort

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

Check if a Node is not a root
DefaultPlotHeight

Calculates the height of a Node given the hight of the root.
as.Node.data.frame

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

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

Cumulate values among siblings
Node

Create a data.tree Structure With Nodes
Get

Traverse a Tree and Collect Values
acme

Sample Data: A Simple Company with Departments
isLeaf

Check if a Node is a leaf
as.phylo.Node

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

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

Executes a function an a set of nodes
FormatFixedDecimal

Format a Number as a Decimal
Traverse

Traverse a tree or a sub-tree
GetAttribute

Get an attribute from a Node.
data.tree

data.tree: Hierarchical Data Structures
as.Node

Convert an object to a data.tree data structure
ClimbByAttribute

Find a Node by provided criteria.
Set

Traverse a Tree and Assign Values
as.igraph.Node

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

Convert a dendrogram to a data.tree Node
isNotLeaf

Check if a Node is not a leaf
isRoot

Check if a Node is the root