sub-mediation_data-ANY-ANY-ANY-method: Subset a mediation dataset

[,mediation_data,ANY,ANY,ANY-methodR Documentation

Subset a mediation dataset

Description

We can subset samples by indexing into a mediation dataset. It will subsample all fields – pretreatments, treatments, mediators, and outcomes. Note that there is no way to subset columns in this way, since they would be different across each source.

Usage

## S4 method for signature 'mediation_data,ANY,ANY,ANY'
x[i, j, ..., drop = TRUE]

Arguments

x

An object of class mediation_data whose samples we want to subset.

i

An integer or integer/logical vector specifying the samples to subset to.

j

A placeholder to argree with R's [ function. Never used.

...

A placeholder to agree with R's [ function. Never used.

drop

A placeholder to agree with R's [ function. Never used.

Value

A version of the input mediation_data object whose @mediators, @outcomes, @treatments, and @pretreatments rows have all been subsetted according to i.

Examples

exper <- demo_joy() |>
    mediation_data("PHQ", "treatment", starts_with("ASV"))
exper[1]
exper[1:10]

multimedia documentation built on Sept. 30, 2024, 9:28 a.m.