distance_matrix: Compute pairwise taxonomic distances for a set of taxa

View source: R/distance.R

distance_matrixR Documentation

Compute pairwise taxonomic distances for a set of taxa

Description

Given a vector of taxon names, computes all pairwise phylogenetic distances and returns a symmetric distance matrix. Lineages are cached after first retrieval to minimise redundant network requests.

Usage

distance_matrix(taxa, verbose = FALSE, progress = TRUE)

Arguments

taxa

A character vector of taxon names.

verbose

Logical. If TRUE, prints progress for each pair. Default FALSE.

progress

Logical. If TRUE, shows a progress bar. Default TRUE.

Value

A symmetric numeric matrix of class "dist" containing pairwise distances. Row and column names are set to the input taxon names. Taxa that could not be found are included with NA distances.

See Also

taxo_distance(), closest_relative()

Examples


theropods <- c("Tyrannosaurus", "Velociraptor", "Spinosaurus",
               "Allosaurus", "Carnotaurus")
mat <- distance_matrix(theropods)
print(mat)


taxodist documentation built on May 6, 2026, 1:06 a.m.