Adds a subspecies column within taxonomic results (e.g. from
make_galah_taxonomy or make_gbif_taxonomy). Simultaneously creates a
rank_adj
column that relevels any rank below subspecies to subspecies (i.e.
any rank = form or variety will have rank_adj = subspecies)
Dataframe. Probably from call to galah::search_taxa()
Ordered factor. Ideally with a match for each unique rank
in tax_res
Character. Vector of regex to remove from scientific_name before creating the subspecies column
tax_res
with extra columns subspecies
and rank_adj
. rank
will
be an ordered factor.
taxa <- c("Acacia lanigera", "Acacia lanigera var. gracilipes", "Spyridium glabrisepalum", "Spyridium eriocephalum var. glabrisepalum")
taxonomy_result <- galah::search_taxa(taxa)
make_subspecies_col(taxonomy_result) |> dplyr::select(search_term, species, subspecies, rank, rank_adj)
#> # A tibble: 4 × 5
#> search_term species subspecies rank rank_adj
#> <chr> <chr> <chr> <ord> <ord>
#> 1 Acacia lanigera Acacia la… NA spec… species
#> 2 Acacia lanigera var. gracilipes Acacia la… Acacia la… vari… subspec…
#> 3 Spyridium glabrisepalum Spyridium… Spyridium… vari… subspec…
#> 4 Spyridium eriocephalum var. glabrisepalum Spyridium… Spyridium… vari… subspec…