Skip to contents

Get the indexes of root taxa in a taxonomy.

Usage

roots(x, subset = NULL)

Arguments

x

An object containing taxonomic relationships, such as taxonomy objects.

subset

The subset of the tree to search for roots to that subset. Can be indexes or names.

See also

Other taxonomy functions: internodes(), leaves(), stems(), subtaxa(), supertaxa()

Other root functions: is_root()

Examples

x <- taxonomy(c('Carnivora', 'Felidae', 'Panthera', 'Panthera leo',
                'Panthera tigris', 'Ursidae', 'Ursus', 'Ursus arctos'),
              supertaxa = c(NA, 1, 2, 3, 3, 1, 6, 7))
roots(x)
#> [1] 1
roots(x, subset = 2:8)
#> [1] 2 6