Skip to contents

Produces a concise descriptive summary of a data frame — mean ± SD for continuous variables and n (%) for categorical variables — with no group comparisons or statistical tests.

Usage

tbl_simple(
  data,
  vars = NULL,
  domains = list(),
  log_vars = character(0),
  digits = 2,
  output = c("gt", "html", "latex")
)

Arguments

data

A data frame.

vars

<tidy-select> Variables to include. Defaults to all columns.

domains

A named list mapping variable names to domain/section labels.

log_vars

Character vector of log-transformed variable names.

digits

Integer. Decimal places for continuous variables (default 2).

output

Character string. One of "gt" (default), "html", or "latex".

Value

A clerk_tbl object with type "simple".

Examples

tbl_simple(
  clerk_example,
  domains = list(
    "Metabolic"     = c("hdl", "glucose", "bmi"),
    "Cognitive"     = c("tmt_time", "verbal_fluency"),
    "Mental health" = c("bdi", "panas_neg", "life_satisfaction")
  ),
  log_vars = "tmt_time",
  output   = "gt"
) |> clerk_render(title = "Descriptive statistics")
#> Warning: invalid factor level, NA generated
Descriptive statistics
n Summary
NA
sex 300 Female: 193 (64.3%); Male: 107 (35.7%)
age 300 46.76 ± 14.15
waist 300 92.07 ± 11.56
systolic_bp 300 123.25 ± 17.77
Metabolic
hdl 300 46.81 ± 10.11
glucose 300 91.68 ± 24.65
bmi 300 26.15 ± 4.91
Cognitive
tmt_time1 300 129.24 ± 64.98
verbal_fluency 300 14.98 ± 4.63
Mental health
bdi 300 13.64 ± 9.26
panas_neg 300 20.98 ± 7.48
life_satisfaction 300 18.02 ± 4.23
1 Log-transformed variables shown on raw scale.