Sort rows of tables or the elements of lists/vectors in the obj$data list in taxmap() objects. Any variable name that appears in all_names() can be used as if it was a vector on its own. See dplyr::arrange() for the inspiration for this function and more information. Calling the function using the obj$arrange_obs(...) style edits "obj" in place, unlike most R functions. However, calling the function using the arrange_obs(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_obs(data, ...)
arrange_obs(obj, data, ...)

Arguments

obj

An object of type taxmap().

data

Dataset names, indexes, or a logical vector that indicates which datasets in obj$data to sort If multiple datasets are sorted at once, then they must be the same length.

...

One or more expressions (e.g. column names) to sort on.

target

DEPRECIATED. use "data" instead.

Value

An object of type taxmap()

See also

Examples

# Sort in ascending order arrange_obs(ex_taxmap, "info", n_legs)
#> <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 q tomato 0 FALSE #> 2 r potato 0 FALSE #> 3 p human 2 TRUE #> # … 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
arrange_obs(ex_taxmap, "foods", name)
#> <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: #> n, p, o, r, m, q #> 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 in decending order arrange_obs(ex_taxmap, "info", desc(n_legs))
#> <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
# Sort multiple datasets at once arrange_obs(ex_taxmap, c("info", "phylopic_ids", "foods"), n_legs)
#> <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 q tomato 0 FALSE #> 2 r potato 0 FALSE #> 3 p human 2 TRUE #> # … with 3 more rows #> phylopic_ids: a named vector of 'character' with 6 items #> q. b6400f39-345a-47[truncated] ... o. 11b783d5-af1c-4f[truncated] #> foods: a list of 6 items named by taxa: #> q, r, p, m, n, o #> 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