Replace taxon ids in a taxmap() or taxonomy() object.

obj$replace_taxon_ids(new_ids)
replace_taxon_ids(obj, new_ids)

Arguments

obj

The taxonomy() or taxmap() object.

new_ids

A vector of new ids, one per taxon. They must be unique and in the same order as the corresponding ids in obj$taxon_ids().

Value

A taxonomy() or taxmap() object with new taxon ids

Examples

# Replace taxon IDs with numbers replace_taxon_ids(ex_taxmap, seq_len(length(ex_taxmap$taxa)))
#> <Taxmap> #> 17 taxa: 1. Mammalia, 2. Plantae ... 17. tuberosum #> 17 edges: NA->1, NA->2, 1->3, 1->4 ... 10->15, 11->16, 11->17 #> 4 data sets: #> info: #> # A tibble: 6 x 4 #> taxon_id name n_legs dangerous #> <int> <chr> <dbl> <lgl> #> 1 12 tiger 4 TRUE #> 2 13 cat 4 FALSE #> 3 14 mole 4 FALSE #> # … with 3 more rows #> phylopic_ids: a named vector of 'character' with 6 items #> 12. e148eabb-f138-4[truncated] ... 17. 63604565-0406-4[truncated] #> foods: a list of 6 items named by taxa: #> 12, 13, 14, 15, 16, 17 #> abund: #> # A tibble: 8 x 5 #> taxon_id code sample_id count taxon_index #> <int> <fct> <fct> <dbl> <int> #> 1 12 T A 1 1 #> 2 13 C A 2 2 #> 3 14 M B 5 3 #> # … with 5 more rows #> 1 functions: #> reaction
# Make taxon IDs capital letters replace_taxon_ids(ex_taxmap, toupper(taxon_ids(ex_taxmap)))
#> <Taxmap> #> 17 taxa: B. Mammalia, C. Plantae ... Q. lycopersicum, R. tuberosum #> 17 edges: NA->B, NA->C, B->D, B->E ... J->O, K->P, L->Q, L->R #> 4 data sets: #> info: #> # A tibble: 6 x 4 #> taxon_id name n_legs dangerous #> <chr> <chr> <dbl> <lgl> #> 1 M tiger 4 TRUE #> 2 N cat 4 FALSE #> 3 O mole 4 FALSE #> # … with 3 more rows #> phylopic_ids: a named vector of 'character' with 6 items #> M. e148eabb-f138-43[truncated] ... R. 63604565-0406-46[truncated] #> foods: a list of 6 items named by taxa: #> M, N, O, P, Q, R #> abund: #> # A tibble: 8 x 5 #> taxon_id code sample_id count taxon_index #> <chr> <fct> <fct> <dbl> <int> #> 1 M T A 1 1 #> 2 N C A 2 2 #> 3 O M B 5 3 #> # … with 5 more rows #> 1 functions: #> reaction