metacoder (version 0.3.7)

select_obs: Subset columns in a [taxmap()] object

Description

Subsets columns in a [taxmap()] object. Takes and returns a [taxmap()] object. Any variable name that appears in [all_names()] can be used as if it was a vector on its own. See [dplyr::select()] for the inspiration for this function and more information. Calling the function using the `obj$select_obs(...)` style edits "obj" in place, unlike most R functions. However, calling the function using the `select_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$select_obs(data, ...)
select_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 tables in `obj$data` to subset columns in. Multiple tables can be subset at once.

...

One or more column names to return in the new object. Each can be one of two things:

expression with unquoted column name

The name of a column in the dataset typed as if it was a variable on its own.

`numeric`

Indexes of columns in the dataset

To match column names with a character vector, use `matches("my_col_name")`. To match a logical vector, convert it to a column index using `which`.

target

DEPRECIATED. use "data" instead.

See Also

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

Examples

Run this code
# Selecting a column by name
select_obs(ex_taxmap, "info", dangerous)

# Selecting a column by index
select_obs(ex_taxmap, "info", 3)

# Selecting a column by regular expressions
select_obs(ex_taxmap, "info", matches("^n"))

Run the code above in your browser using DataLab