slice: Subset to a specific number of samples.

sliceR Documentation

Subset to a specific number of samples.

Description

Subset to a specific number of samples.

Usage

## S3 method for class 'rbiom'
slice(biom, ..., clone = TRUE)

## S3 method for class 'rbiom'
slice_head(biom, ..., clone = TRUE)

## S3 method for class 'rbiom'
slice_tail(biom, ..., clone = TRUE)

## S3 method for class 'rbiom'
slice_min(biom, ..., clone = TRUE)

## S3 method for class 'rbiom'
slice_max(biom, ..., clone = TRUE)

## S3 method for class 'rbiom'
slice_sample(biom, ..., clone = TRUE)

Arguments

biom

An rbiom object, such as from as_rbiom().

...

Passed on to dplyr::slice().

clone

Create a copy of biom before modifying. If FALSE, biom is modified in place as a side-effect. See speed ups for use cases. Default: TRUE

Value

An rbiom object.

See Also

Other transformations: mutate(), rarefy(), rarefy_cols(), subset(), with()

Examples

    library(rbiom)
    
    # The last 3 samples in the metadata table.
    biom <- slice_tail(hmp50, n = 3)
    biom$metadata
    
    # The 3 oldest subjects sampled.
    biom <- slice_max(hmp50, Age, n = 3)
    biom$metadata
    
    # Pick 3 samples at random.
    biom <- slice_sample(hmp50, n = 3)
    biom$metadata


cmmr/rbiom documentation built on April 28, 2024, 6:38 a.m.