Convert per-taxon information, like taxon names, to a table of taxa (rows) by ranks (columns).

Arguments

obj

A taxonomy or taxmap object

subset

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

value

What data to return. Default is taxon names. Any result of all_names() can be used, but it usually only makes sense to use data with one value per taxon, like taxon names.

use_ranks

Which ranks to use. Must be one of the following:

  • NULL (the default): If there is rank information, use the ranks that appear in the lineage with the most ranks. Otherwise, assume the number of supertaxa corresponds to rank and use placeholders for the rank column names in the output.

  • TRUE: Use the ranks that appear in the lineage with the most ranks. An error will occur if no rank information is available.

  • FALSE: Assume the number of supertaxa corresponds to rank and use placeholders for the rank column names in the output. Do not use included rank information.

  • character: The names of the ranks to use. Requires included rank information.

  • numeric: The "depth" of the ranks to use. These are equal to n_supertaxa + 1.

add_id_col

If TRUE, include a taxon ID column.

Value

A tibble of taxa (rows) by ranks (columns).

Examples

# Make a table of taxon names taxonomy_table(ex_taxmap)
#> The following ranks will not be included because the order cannot be determined: #> kingdom #> See the section on the `use_ranks` option in ?taxonomy_table to if you want to change which ranks are used.
#> # A tibble: 6 x 4 #> class family genus species #> <chr> <chr> <chr> <chr> #> 1 Mammalia Felidae Panthera tigris #> 2 Mammalia Felidae Felis catus #> 3 Mammalia Notoryctidae Notoryctes typhlops #> 4 Mammalia Hominidae homo sapiens #> 5 NA Solanaceae Solanum lycopersicum #> 6 NA Solanaceae Solanum tuberosum
# Use a differnt value taxonomy_table(ex_taxmap, value = "taxon_ids")
#> The following ranks will not be included because the order cannot be determined: #> kingdom #> See the section on the `use_ranks` option in ?taxonomy_table to if you want to change which ranks are used.
#> # A tibble: 6 x 4 #> class family genus species #> <chr> <chr> <chr> <chr> #> 1 b d h m #> 2 b d i n #> 3 b e j o #> 4 b f k p #> 5 NA g l q #> 6 NA g l r
# Return a subset of taxa taxonomy_table(ex_taxmap, subset = taxon_ranks == "genus")
#> The following ranks will not be included because the order cannot be determined: #> kingdom #> See the section on the `use_ranks` option in ?taxonomy_table to if you want to change which ranks are used.
#> # A tibble: 5 x 3 #> class family genus #> <chr> <chr> <chr> #> 1 Mammalia Felidae Panthera #> 2 Mammalia Felidae Felis #> 3 Mammalia Notoryctidae Notoryctes #> 4 Mammalia Hominidae homo #> 5 NA Solanaceae Solanum
# Use arbitrary ranks names based on depth taxonomy_table(ex_taxmap, use_ranks = FALSE)
#> # A tibble: 6 x 4 #> rank_1 rank_2 rank_3 rank_4 #> <chr> <chr> <chr> <chr> #> 1 Mammalia Felidae Panthera tigris #> 2 Mammalia Felidae Felis catus #> 3 Mammalia Notoryctidae Notoryctes typhlops #> 4 Mammalia Hominidae homo sapiens #> 5 Plantae Solanaceae Solanum lycopersicum #> 6 Plantae Solanaceae Solanum tuberosum