n_subtaxa: Number of subtaxa per taxon

Description Usage Arguments See Also Examples

View source: R/taxonomy.R

Description

Get the number of subtaxa per taxon.

Usage

1
n_subtaxa(x, subset = NULL, max_depth = NULL, include = FALSE)

Arguments

x

The object to get subtaxa for, such as a taxonomy object.

subset

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

max_depth

The number of ranks to traverse. For example, max_depth = 1 returns only immediate subtaxa. By default (NULL) information for all subtaxa is returned (i.e. subtaxa of subtaxa, etc).

include

If TRUE, include information for each taxon in the output.

See Also

Other subtaxa functions: subtaxa()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# Generate example data
x <- taxonomy(c('Carnivora', 'Felidae', 'Panthera', 'Panthera leo',
                'Panthera tigris', 'Ursidae', 'Ursus', 'Ursus arctos'),
              supertaxa = c(NA, 1, 2, 3, 3, 1, 6, 7))

# Find number of subtaxa (including subtaxa of subtaxa, etc)
n_subtaxa(x)

# Find the number of subtaxa one rank below each taxon
n_subtaxa(x, max_depth = 1)

# Only return data for some taxa (faster than subsetting the whole result)
n_subtaxa(x, subset = 1:3)

zachary-foster/taxa2 documentation built on Jan. 1, 2021, 1:48 p.m.