bind_mediation: Convert 'mediation_data' to a single data.frame

View source: R/mediation.R

bind_mediationR Documentation

Convert mediation_data to a single data.frame

Description

It can be helpful to combine all the data in a mediation_data S4 object into a single data.frame. This concatenates all data sources horizontally, into an N samples x (all outcomes, mediators, treatments, ...) matrix.

Usage

bind_mediation(exper)

Arguments

exper

An object of class mediation_data containing the variables that we want horizontally concatenated.

Value

A data.frame containing all variables from the original mediation_data object.

Examples

exper <- demo_joy() |>
    mediation_data("PHQ", "treatment", starts_with("ASV"))
exper
bind_mediation(exper)

exper <- demo_spline(tau = c(2, 1)) |>
    mediation_data(starts_with("outcome"), "treatment", "mediator")
exper
bind_mediation(exper)

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