Return the leaf taxa for a taxonomy() or taxmap() object. Leaf taxa are taxa with no subtaxa.

obj$leaves(subset = NULL, recursive = TRUE, simplify = FALSE, value = "taxon_indexes")
leaves(obj, subset = NULL, recursive = TRUE, simplify = FALSE, value = "taxon_indexes")

Arguments

obj

The taxonomy() or taxmap() object containing taxon information to be queried.

subset

Taxon IDs, TRUE/FALSE vector, or taxon indexes to find leaves for. Default: All taxa in obj will be used. Any variable name that appears in all_names() can be used as if it was a vector on its own.

recursive

(logical or numeric) If FALSE, only return the leaves if they occur one rank below the target taxa. If TRUE, return all of the leaves for each taxon. Positive numbers indicate the number of recursions (i.e. number of ranks below the target taxon to return). 1 is equivalent to FALSE. Negative numbers are equivalent to TRUE.

simplify

(logical) If TRUE, then combine all the results into a single vector of unique values.

value

What data to return. This is usually the name of column in a table in obj$data. Any result of all_names(obj) can be used, but it usually only makes sense to data that corresponds to taxa 1:1, such as taxon_ranks(). By default, taxon indexes are returned.

Value

character

See also

Other taxonomy indexing functions: branches(), internodes(), roots(), stems(), subtaxa(), supertaxa()

Examples

# Return indexes of leaf taxa leaves(ex_taxmap)
#> $b #> m n o p #> 12 13 14 15 #> #> $c #> q r #> 16 17 #> #> $d #> m n #> 12 13 #> #> $e #> o #> 14 #> #> $f #> p #> 15 #> #> $g #> q r #> 16 17 #> #> $h #> m #> 12 #> #> $i #> n #> 13 #> #> $j #> o #> 14 #> #> $k #> p #> 15 #> #> $l #> q r #> 16 17 #> #> $m #> named integer(0) #> #> $n #> named integer(0) #> #> $o #> named integer(0) #> #> $p #> named integer(0) #> #> $q #> named integer(0) #> #> $r #> named integer(0) #>
# Return indexes for a subset of taxa leaves(ex_taxmap, subset = 2:17)
#> $c #> q r #> 16 17 #> #> $d #> m n #> 12 13 #> #> $e #> o #> 14 #> #> $f #> p #> 15 #> #> $g #> q r #> 16 17 #> #> $h #> m #> 12 #> #> $i #> n #> 13 #> #> $j #> o #> 14 #> #> $k #> p #> 15 #> #> $l #> q r #> 16 17 #> #> $m #> named integer(0) #> #> $n #> named integer(0) #> #> $o #> named integer(0) #> #> $p #> named integer(0) #> #> $q #> named integer(0) #> #> $r #> named integer(0) #>
leaves(ex_taxmap, subset = taxon_names == "Plantae")
#> $c #> q r #> 16 17 #>
# Return something besides taxon indexes leaves(ex_taxmap, value = "taxon_names")
#> $b #> m n o p #> "tigris" "catus" "typhlops" "sapiens" #> #> $c #> q r #> "lycopersicum" "tuberosum" #> #> $d #> m n #> "tigris" "catus" #> #> $e #> o #> "typhlops" #> #> $f #> p #> "sapiens" #> #> $g #> q r #> "lycopersicum" "tuberosum" #> #> $h #> m #> "tigris" #> #> $i #> n #> "catus" #> #> $j #> o #> "typhlops" #> #> $k #> p #> "sapiens" #> #> $l #> q r #> "lycopersicum" "tuberosum" #> #> $m #> named character(0) #> #> $n #> named character(0) #> #> $o #> named character(0) #> #> $p #> named character(0) #> #> $q #> named character(0) #> #> $r #> named character(0) #>
leaves(ex_taxmap, subset = taxon_ranks == "genus", value = "taxon_names")
#> $h #> m #> "tigris" #> #> $i #> n #> "catus" #> #> $j #> o #> "typhlops" #> #> $k #> p #> "sapiens" #> #> $l #> q r #> "lycopersicum" "tuberosum" #>
# Return a vector of all unique values leaves(ex_taxmap, value = "taxon_names", simplify = TRUE)
#> m n o p q #> "tigris" "catus" "typhlops" "sapiens" "lycopersicum" #> r #> "tuberosum"
# Only return leaves for their direct supertaxa leaves(ex_taxmap, value = "taxon_names", recursive = FALSE)
#> $b #> named character(0) #> #> $c #> named character(0) #> #> $d #> named character(0) #> #> $e #> named character(0) #> #> $f #> named character(0) #> #> $g #> named character(0) #> #> $h #> m #> "tigris" #> #> $i #> n #> "catus" #> #> $j #> o #> "typhlops" #> #> $k #> p #> "sapiens" #> #> $l #> q r #> "lycopersicum" "tuberosum" #> #> $m #> named character(0) #> #> $n #> named character(0) #> #> $o #> named character(0) #> #> $p #> named character(0) #> #> $q #> named character(0) #> #> $r #> named character(0) #>