Skip to contents

This function is a wrapper around gtsummary::tbl_summary that ensures continuous variables are treated as continuous.

Usage

MakeTable1(
  data,
  variables = NULL,
  TreatOrdinalAs = "Categorical",
  Relabel = TRUE,
  AutoDetectDistribution = FALSE,
  IncludeMissing = "ifany",
  DataFrame = lifecycle::deprecated(),
  Variables = lifecycle::deprecated()
)

Arguments

data

The dataframe to create the summary table from.

variables

Optional. A character vector specifying the names of variables to include in the summary table. If NULL, all variables are included.

TreatOrdinalAs

Character. Specifies how ordinal variables should be treated. Can be "Continuous", "Categorical", or "Both".

Relabel

Logical; if TRUE (default), use attached variable labels.

AutoDetectDistribution

Logical. If TRUE, the function will attempt to automatically detect the distribution of variables. Default is FALSE.

IncludeMissing

Character matching gtsummary criteria. Can be "no", "ifany", or "always". Default is "ifany"

DataFrame

Deprecated (since 19.15.0). Use data instead.

Variables

Deprecated (since 19.15.0). Use variables instead.

Value

A summary table created using gtsummary.

References

This function wraps gtsummary. Please cite:

Sjoberg, D. D., Whiting, K., Curry, M., Lavery, J. A., & Larmarange, J. (2021). Reproducible summary tables with the gtsummary package. The R Journal, 13(1), 570-580. doi:10.32614/RJ-2021-053

Examples

data(SampleData)
data(SampleVariableTypes)

# Attach labels and factor levels so the table is publication-ready
Labelled <- RevalueData(SampleData, SampleVariableTypes)$RevaluedData

# A Table 1 across 16 mixed-type variables
vars <- c(
  "Diagnosis", "age", "sex", "Genotype", "AXL", "Adiponectin",
  "Alpha_1_Antitrypsin", "Alpha_2_Macroglobulin", "Apolipoprotein_A1",
  "Apolipoprotein_B", "C_Reactive_Protein", "Cortisol", "Cystatin_C",
  "Ferritin", "Insulin", "Leptin"
)

MakeTable1(Labelled, variables = vars)
Characteristic N = 3331
Diagnosis
    Control 242 (73%)
    Impaired 91 (27%)
Age 72 (13)
    Unknown 11
Sex
    Female 204 (61%)
    Male 129 (39%)
Genotype
    E2E2 2 (0.6%)
    E2E3 37 (11%)
    E2E4 8 (2.4%)
    E3E3 167 (50%)
    E3E4 106 (32%)
    E4E4 13 (3.9%)
AXL receptor tyrosine kinase 0.30 (0.45)
Adiponectin -5.22 (0.67)
Alpha-1-antitrypsin -13.14 (1.55)
Alpha-2-macroglobulin -159 (41)
Apolipoprotein A-1 -7.48 (0.44)
Apolipoprotein B -5.59 (1.45)
C-reactive protein -5.90 (1.19)
Cortisol 11.7 (4.0)
Cystatin C 8.58 (0.40)
Ferritin 2.75 (0.78)
Insulin -1.23 (0.34)
Leptin -1.49 (0.27)
1 n (%); Mean (SD)