Skip to content

treebalance

1.2.2Package record

Computation of Tree (Im)Balance Indices

2packages depend
8.7Kdownloads / year
–test coverage
13/13flavors OK

Overview

About

The aim of the 'R' package 'treebalance' is to provide functions for the computation of a large variety of (im)balance indices for rooted trees. The package accompanies the book ''Tree Balance Indices - A Comprehensive Survey'' by M. Fischer, L. Herbst, S. Kersting, L. Kuehn and K. Wicke (2023) doi:10.1007/978-3-031-39800-1, which gives a precise definition for the terms 'balance index' and 'imbalance index' (Chapter 4) and provides an overview of the terminology in this manual (Chapter 2). For further information on (im)balance indices, see also Fischer et al. (2021) https://treebalance.wordpress.com. Considering both established and new (im)balance indices, 'treebalance' provides (among others) functions for calculating the following 18 established indices and index families: the average leaf depth, the B1 and B2 index, the Colijn-Plazzotta rank, the normal, corrected, quadratic and equal weights Colless index, the family of Colless-like indices, the family of I-based indices, the Rogers J index, the Furnas rank, the rooted quartet index, the s-shape statistic, the Sackin index, the symmetry nodes index, the total cophenetic index and the variance of leaf depths. Additionally, we include 6 tree shape statistics that satisfy the definition of an (im)balance index but have not been thoroughly analyzed in terms of tree balance in the literature yet. These are: the maximum width, the modified maximum difference in widths, the maximum depth, the maximum width over maximum depth, the stairs1 and the stairs2 index. As input, most functions of 'treebalance' require a rooted (phylogenetic) tree in 'phylo' format (as introduced in 'ape' 1.9 in November 2006). 'phylo' is used to store (phylogenetic) trees with no vertices of out-degree one. For further information on the format we kindly refer the reader to E. Paradis (2012) https://emmanuelparadis.github.io/misc/FormatTreeR_24Oct2012.pdf.

Changes in 1.2.2
  • **Changed results and return types:** The Wedderburn-Etherington numbers in wedEth are now stored exactly as big integers (bigz, package gmp). Previously they were stored as double, which made them inexact from n = 50 and infinite from n = 793 on. As a consequence, furnasI(), furnasI_inv(), treenumber(), treenumber_inv() and getfurranks() now compute exactly for all trees with up to 2545 leaves; previously they silently returned wrong results for n >= 51. we_eth() now returns bigz by default.
  • **Changed results and return types:** colPlaLab() now computes the Colijn-Plazzotta rank exactly and returns it as bigz by default; previously the ranks were wrong from n = 10 and infinite from n = 14 on. colPlaLab_inv() and cPL_inv() now also compute exactly.
  • New argument type = "double" in we_eth(), furnasI(), treenumber() and colPlaLab() to obtain the result as double. It is only available as long as all values can be represented exactly (n <= 48, n <= 47 and n <= 9, respectively); otherwise the functions stop.
Show all changes in 1.2.2Hide the rest of the changes in 1.2.2
  • furnasI_inv(), treenumber_inv(), colPlaLab_inv() and cPL_inv() accept the rank as bigz, character or double (the latter up to 2^53).
  • **Changed results:** collesslikeI(dissim = "mdm") now computes the mean deviation from the median as documented. Previously the sum instead of the mean was returned, i.e. the balance value of every vertex was multiplied by its number of children.
  • rQuartetI() now takes the shape value q0 into account (previously it was ignored, so results were only correct for q0 = 0) and checks that shapeVal has exactly 5 entries.
  • B1I(), totCophI() and areaPerPairI() now return 0 (resp. the correct value) for star trees instead of NA.
  • collessI(method = "corrected") now returns 0 for n = 2 as documented instead of NaN.
  • is_binary() now returns FALSE instead of NULL for non-binary trees, so the binary-only functions show their intended error message.
  • collesslikeI() now also accepts functions for f.size and dissim directly, not only their names as strings (needed e.g. for functions defined within another function or package).
  • B2I() and sShapeI() now stop for the invalid logarithm base 1 (and sShapeI() also for non-positive bases) instead of returning Inf/NaN.
  • tree_merge() now also works for trees with edge lengths (previously it failed with "tree 'x' has no root edge") and keeps tip labels and edge lengths when two single leaves are merged.
  • furnasI_inv() and treenumber_inv() now also work when treebalance is not attached, e.g. when used from within another package.
  • Updated the citation to the published book "Tree Balance Indices -- A Comprehensive Survey" (Springer, 2023).

From NEWS.md in the release

Install

Health

CRAN checks
13OK
Slowest check: 1.3 min · r-oldrel-windows-x86_64
Status changes
  • OK13 OK2026-08-04
  • NOTE12 OK, 1 NOTE2026-08-01
  • OK14 OK2026-03-10
Advisories

none known

Documentation

In release 1.2.2
READMENoVignettesNoNEWSYes · 67% structured · mentions 1.2.2Citation fileYes · cites a publicationWebsitenot declared in DESCRIPTION
Help pages
32
Examples that run
100%32 run in a plain check
Exported functions with examples
100%
Documented parameters
99%
Return-value docs
100%
Help pages citing references
91%

Downloads

8.7K
CRAN downloads in the past year
Rank #4,324 · ~24/day · ~722/mo
Daily download trend is not available in this view yet.
55230 days
2K90 days
8.7K1 year
Compare downloads with other packages →
Also on137 r2u3 autocran39 c2d4u

Dependencies

Declared dependencies
3 external dependencies (excludes base and recommended)

Installing treebalance adds 8 packages (7 with compiled code, 4.4 MB of source tarballs). Heaviest: Rcpp 1.8 MB, ape 1.4 MB, rlang 766 KB.

Depends (1)
R >= 3.5.0
Imports (3)
LinkingTo (0)
none
Suggests (0)
none
Enhances (0)
none
Reverse dependencies
2direct
1indirect
Imports 2
Depends, Imports or LinkingTo, most downloaded first

Datasets

People & History

People (5)
Author, Maintainer since 1.0.0 (2021)
Releases (4)

Pick two releases to compare their code metrics.

  • 1.2.2Latest
    record
    2026-10-01 · current release · diff ↗ ·
    removed 1 export
    mCherryI
  • R
    R 4.6.0 released · 2026-04-24
  • R
    R 4.5.0 released · 2025-04-11
  • R
    R 4.4.0 released · 2024-04-24
  • 1.2.0
    record
    2023-12-14 · diff ↗ ·
    added 5 exports
    avgVertDep, mCherryI, mWovermD, totIntPathLen, totPathLen
  • R
    R 4.3.0 released · 2023-04-21
  • R
    R 4.2.0 released · 2022-04-22
  • 1.1.0
    record
    2021-10-17 · diff ↗
  • 1.0.0
    record
    2021-09-22
  • R
    R 4.1.0 released · 2021-05-18

Package metadata

First published
2021-09-22
Total releases
4 / 5 yrs
License
GPL-3 OSI
Minimum R
≥ 3.5.0
Bundled data
526 KB / 1 file
Download size
577 KB
Appears in task views

Cite

Cite this package

Run in R for the authors' entry:

citation("treebalance")

The package provides a citation file, so citation() returns the authors' own entry.

It points to 10.1007/978-3-031-39800-1.

Cite the R Observatory

For a number measured here: a download total, a coverage figure, an archival date.

APA

Balamuta, J. J. (2026). R Observatory: Metrics for treebalance version 1.2.2 [Data set]. HJJB, LLC. Data release v2026-10-22. https://doi.org/10.5281/zenodo.21843040

From data release v2026-10-22, which the citation names so these numbers can be found later. More on citing and the projects behind them.

Report a problem with this page →

Privacy choices

These apply to this browser and are stored on this device only. Nothing about your choice is sent to us.

Read the privacy policy