summary_factorlist_stratified: Summarise a set of factors (or continuous variables) by a...

summary_factorlist_stratifiedR Documentation

Summarise a set of factors (or continuous variables) by a dependent variable

Description

A function that takes a single dependent variable with a vector of explanatory variable names (continuous or categorical variables) to produce a summary table.

Usage

summary_factorlist_stratified(
  .data,
  ...,
  split,
  colname_sep = "|",
  level_max_length = 10,
  n_common_cols = 2
)

Arguments

.data

Dataframe.

...

Arguments to summary_factorlist.

split

Quoted variable name to stratify columns by.

colname_sep

Separator for creation of new column name.

level_max_length

Maximum name for each factor level contributing to column name.

n_common_cols

Number of common columns in summary_factorlist table, usually 2.

Details

This function aims to produce publication-ready summary tables for categorical or continuous dependent variables. It usually takes a categorical dependent variable to produce a cross table of counts and proportions expressed as percentages or summarised continuous explanatory variables. However, it will take a continuous dependent variable to produce mean (standard deviation) or median (interquartile range) for use with linear regression models. Stratify a summary_factorlist table (beta testing)

Value

Dataframe.

Examples

# Table 1 - Perforation status stratified by sex ----
explanatory = c("age", "obstruct.factor")
dependent = "perfor.factor"

# Single split
colon_s %>%
  summary_factorlist_stratified(dependent, explanatory, split = c("sex.factor"))

# Double split
colon_s %>%
 summary_factorlist_stratified(dependent, explanatory, split = c("sex.factor", "age.factor"))

finalfit documentation built on Sept. 11, 2024, 9:01 p.m.