Sort the edge list and taxon list in taxonomy()
or taxmap()
objects. See
dplyr::arrange()
for the inspiration for this function and more
information. Calling the function using the obj$arrange_taxa(...)
style
edits "obj" in place, unlike most R functions. However, calling the function
using the arrange_taxa(obj, ...)
imitates R's traditional copy-on-modify
semantics, so "obj" would not be changed; instead a changed version would be
returned, like most R functions.
obj$arrange_taxa(...) arrange_taxa(obj, ...)
obj | |
---|---|
... | One or more expressions (e.g. column names) to sort on. Any
variable name that appears in |
An object of type taxonomy()
or taxmap()
Other taxmap manipulation functions:
arrange_obs()
,
filter_obs()
,
filter_taxa()
,
mutate_obs()
,
sample_frac_obs()
,
sample_frac_taxa()
,
sample_n_obs()
,
sample_n_taxa()
,
select_obs()
,
transmute_obs()
# Sort taxa in ascending order arrange_taxa(ex_taxmap, taxon_names)#> <Taxmap> #> 17 taxa: n. catus, d. Felidae ... r. tuberosum, o. typhlops #> 17 edges: i->n, b->d, d->i, b->f, f->k ... g->l, h->m, l->r, j->o #> 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# Sort taxa in decending order arrange_taxa(ex_taxmap, desc(taxon_names))#> <Taxmap> #> 17 taxa: o. typhlops, r. tuberosum ... d. Felidae, n. catus #> 17 edges: j->o, l->r, h->m, g->l, c->g ... b->f, d->i, b->d, i->n #> 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# Sort using an expression. List genera first. arrange_taxa(ex_taxmap, taxon_ranks != "genus")#> <Taxmap> #> 17 taxa: h. Panthera, i. Felis ... q. lycopersicum, r. tuberosum #> 17 edges: d->h, d->i, e->j, f->k, g->l ... 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