Skip to contents

Creates a comparison table (via gtsummary) that • summarises variables by a grouping factor, • optionally adjusts continuous outcomes for covariates (ANCOVA), • adds p-values, effect sizes, and pair-wise contrasts, • automatically drops constant variables, and • can suppress the “Unknown” row or add an overall N column.

Usage

MakeComparisonTable(
  DataFrame,
  Variables,
  CompVariable,
  Covariates = NULL,
  ValueDigits = 2,
  pDigits = 3,
  AddEffectSize = FALSE,
  EffectSizeDigits = 2,
  AddPairwise = FALSE,
  PairwiseMethod = "bonferroni",
  Parametric = TRUE,
  IncludeOverallN = FALSE,
  IncludeMissing = FALSE,
  suppress_warnings = FALSE,
  Referent = NULL
)

Arguments

DataFrame

Data frame with the raw data.

Variables

Character vector of columns to compare.

CompVariable

Grouping / comparison variable.

Covariates

Optional covariates (default NULL).

ValueDigits

Digits in summary stats (default 2).

pDigits

Digits in p-values (default 3).

AddEffectSize

Logical; add effect sizes? (default FALSE).

EffectSizeDigits

Digits in effect sizes (default 2).

AddPairwise

Logical; add pair-wise contrasts? (default FALSE).

PairwiseMethod

P-adjustment method (default "bonferroni").

Parametric

TRUE = parametric, FALSE = non-parametric tests.

IncludeOverallN

Logical; add overall N? (default FALSE).

IncludeMissing

Logical; include “Unknown” row? (default FALSE).

suppress_warnings

Suppress gtsummary warnings? (default FALSE).

Referent

Optional reference level for contrasts.

Value

A gtsummary::tbl_summary object.