Creates comprehensive tables for categorical or continuous variables with formatting, statistical tests, prevalence ratios (PR), odds ratios (OR), and column stratification.
tb(
data,
...,
m = FALSE,
d = 1,
format = TRUE,
style = "n_pct",
style.rp = "{rp} ({lower} - {upper})",
style.or = "{or} ({lower} - {upper})",
test = FALSE,
subset = NULL,
strat = NULL,
rp = FALSE,
or = FALSE,
ref = NULL,
conf.level = 0.95,
var.type = NULL,
stat.cont = "median"
)An object of class tb (a matrix with attributes).
A data.frame or atomic vector.
Variables to be tabulated. Accepts variable names and/or flags
(m, p, row, col, rp, or) for controlling output format.
Logical. Include missing values (NA) in the table. Default: FALSE.
Integer. Decimal places for percentages and statistics. Default: 1.
Logical. Render a formatted grid output. Default: TRUE.
Character. Format for displaying counts and percentages.
Options: "n_pct" (default), "pct_n", or a custom template with {n} and
{p} placeholders, e.g. "{n} [{p}%]".
Character. Format string for Prevalence Ratio.
Default: "{rp} ({lower} - {upper})".
Character. Format string for Odds Ratio.
Default: "{or} ({lower} - {upper})".
Logical or Character. Performs statistical test on 2x2+ tables.
TRUE for automatic selection, or one of "chisq", "fisher", "mcnemar".
Logical expression for row filtering.
Variable for column stratification. Disables PR/OR calculations.
Logical. Calculate Prevalence Ratios (PR). Default: FALSE.
Logical. Calculate Odds Ratios (OR). Default: FALSE.
Character or numeric. Reference level for PR/OR calculations.
Numeric. Confidence level for intervals (0-1). Default: 0.95.
Named character vector specifying variable types, e.g.
c(age = "continuous").
Character. "mean" (Mean/SD) or "median" (Median/IQR).
Default: "median".