stack_data: Return a list with stacked data sets for each of the outcome...

stack_dataR Documentation

Return a list with stacked data sets for each of the outcome pairs

Description

Takes a data.frame in with longitudinal data to be used in the multivariate mixed model function. Uses the pairwise combination created with the make_pairs() function to unroll the outcome matrix into a vector. The longitudinal predictor and time invariant covariates are processed accordingly.

Usage

stack_data(data, id, pairs, covars = NULL)

Arguments

data

A data.frame with the longitudinal data in long format.

id

A character value with the variable name of the subject identifier.

pairs

A character matrix with the pairs, returned from the make_pairs function

covars

(optional) a character vector with the names of the covariate vectors.

Value

a list of data.frames of length nrow(pairs).

Examples

## Not run: 
df_stacked <- stack_data(
  data = df,
  id = "id",
  pairs = pairs,
  covars = c("time", "sex", "time_failure")
)

## End(Not run)

JanvandenBrand/jmmm documentation built on May 30, 2022, 9:37 a.m.