selecters: Subset a mudata object by identifier

select_datasetsR Documentation

Subset a mudata object by identifier

Description

These functions use dplyr-like selection syntax to quickly subset a mudata object by param, location, or dataset. Params, locations, an datasets can also be renamed using keyword arguments, identical to dplyr selection syntax.

Usage

select_datasets(.data, ...)

## Default S3 method:
select_datasets(.data, ..., .factor = FALSE)

select_locations(.data, ...)

## Default S3 method:
select_locations(.data, ..., .factor = FALSE)

select_params(.data, ...)

## Default S3 method:
select_params(.data, ..., .factor = FALSE)

Arguments

.data

A mudata object

...

Quoted names, bare names, or helpers like starts_with, contains, ends_with, one_of, or matches.

.factor

If TRUE, the new object will keep the order specified by converting columns to factors. This may be useful for specifying order when using ggplot2.

Value

A subsetted mudata object.

See Also

select, rename_locations, distinct_locations, filter_locations

Examples

# renaming can be handy when locations are verbosely named
ns_climate %>%
  select_locations(
    sable_island = starts_with("SABLE"),
    nappan = starts_with("NAPPAN"),
    baddeck = starts_with("BADDECK")
  ) %>%
  select_params(ends_with("temp"))

# can also use quoted values
long_lake %>%
  select_params("Pb", "As", "Cr")

# can also use negative values to remove params/datasets/locations
long_lake %>%
  select_params(-Pb)

# to get around non-standard evaluation, use one_of()
my_params <- c("Pb", "As", "Cr")
long_lake %>%
  select_params(one_of(my_params))


mudata2 documentation built on Jan. 22, 2023, 1:48 a.m.