Learn R Programming

metacoder (version 0.3.7)

arrange_obs: Sort user data in [taxmap()] objects

Description

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, ...)

Value

An object of type [taxmap()]

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.

See Also

Other taxmap manipulation functions: arrange_taxa(), filter_obs(), filter_taxa(), mutate_obs(), sample_frac_obs(), sample_frac_taxa(), sample_n_obs(), sample_n_taxa(), select_obs(), transmute_obs()

Examples

Run this code
# Sort in ascending order
arrange_obs(ex_taxmap, "info", n_legs)
arrange_obs(ex_taxmap, "foods", name)

# Sort in decending order
arrange_obs(ex_taxmap, "info", desc(n_legs))

# Sort multiple datasets at once
arrange_obs(ex_taxmap, c("info", "phylopic_ids", "foods"), n_legs)

Run the code above in your browser using DataLab