gather_strat_multi_variable: A Function to Gather Multiple Stratified Variables into a...

View source: R/gather_strat_multi_variable.R

gather_strat_multi_variableR Documentation

A Function to Gather Multiple Stratified Variables into a Tidy Format

Description

A Function to Gather Multiple Stratified Variables into a Tidy Format

Usage

gather_strat_multi_variable(
  df,
  id_col,
  compartments = NULL,
  hold_out_var = NULL,
  strat = NULL,
  groups = NULL
)

Arguments

df

A data frame with variables stratified using numeric labels.

id_col

A character string containing the name of the new id column.

compartments

A character vector specifying the unique population compartments.

hold_out_var

A character vector specifying the variables to keep unchanged. Defaults to NULL

strat

An integer specifying the number of stratifications to reduce.

groups

A character vector with length equal to the level of stratification. Used to name the stratified levels.

Value

A dataframe of stratified model output with multiple Tidy variables.

Examples



df <- data.frame(time = 0, A1 = 1, A2 = 2, A3 = 3, B1 = 2, B2 = 3, B3 = 0)
gather_strat_multi_variable(df, id_col = "Age", compartment = c("A", "B"), hold_out_var = "time",
                            strat = 3, groups = c("Children", "Young adults", "Adults"))


idmodelr documentation built on Sept. 2, 2022, 5:06 p.m.