A descriptive table summarizes the analyzed data, usually by group.
In infereportR such a table states its denominators and missing counts,
contains no hypothesis test by default, and keeps any added inference
apart from the descriptive summaries. This vignette uses the
ToothGrowth data set that ships with R.
ToothGrowth records the length of odontoblasts, the
cells responsible for tooth growth, in 60 guinea pigs. Each animal
received vitamin C as orange juice (OJ) or ascorbic acid
(VC) at one of three daily doses. Two lengths are set to
missing here to show how denominators are reported, and the dose is
treated as an ordered category.
tg <- ToothGrowth
tg$dose <- factor(tg$dose, levels = c(0.5, 1, 2), ordered = TRUE)
tg$len[c(3, 41)] <- NAGiven a data frame, report_descriptive() asks
infercalcR::describe_data() for the summaries and formats
the result. Labels and units are optional and are matched by variable
name:
desc <- report_descriptive(tg, group = "supp",
labels = c(len = "Odontoblast length", dose = "Daily dose"),
units = c(dose = "mg/day"))Continuous variables are summarized by mean, standard deviation,
median, quartiles, minimum and maximum. Each row reports the number of
observations used (n), the number missing
(n.missing) and the group total (n.total):
continuous <- desc$variable_type == "continuous" &
desc$estimand %in% c("mean", "sd", "median")
desc[continuous, c("group", "label", "estimand", "estimate_display",
"n", "n.missing", "n.total")]
#> group label estimand estimate_display n n.missing n.total
#> 1 VC Odontoblast length mean 17.3 29 1 30
#> 2 VC Odontoblast length sd 8.2 29 1 30
#> 3 VC Odontoblast length median 16.5 29 1 30
#> 11 OJ Odontoblast length mean 20.7 29 1 30
#> 12 OJ Odontoblast length sd 6.72 29 1 30
#> 13 OJ Odontoblast length median 23 29 1 30Categorical variables, including ordered factors, are reported as counts with proportions of the nonmissing observations in each group:
desc[desc$variable_type == "categorical",
c("group", "label", "unit", "level", "estimate_display", "proportion", "n")]
#> group label unit level estimate_display proportion n
#> 8 VC Daily dose mg/day 0.5 10 0.3333333 30
#> 9 VC Daily dose mg/day 1 10 0.3333333 30
#> 10 VC Daily dose mg/day 2 10 0.3333333 30
#> 18 OJ Daily dose mg/day 0.5 10 0.3333333 30
#> 19 OJ Daily dose mg/day 1 10 0.3333333 30
#> 20 OJ Daily dose mg/day 2 10 0.3333333 30The table is a plain data frame in long format. Base R can reshape it into the familiar layout with one column per group:
summary_rows <- desc[desc$estimand %in% c("mean", "sd"),
c("label", "estimand", "group", "estimate_display")]
reshape(summary_rows, idvar = c("label", "estimand"), timevar = "group",
direction = "wide")
#> label estimand estimate_display.VC estimate_display.OJ
#> 1 Odontoblast length mean 17.3 20.7
#> 2 Odontoblast length sd 8.2 6.72No p-value columns are created and no test is chosen automatically.
A description can also be computed once with infercalcR and reported later. In that case the selection and labeling arguments are not used, since they already belong to the stored result:
stored <- describe_data(tg, variables = "len", group = "supp")
report_descriptive(stored)[, c("group", "estimand", "estimate_display", "n")]
#> group estimand estimate_display n
#> 1 VC mean 17.3 29
#> 2 VC sd 8.2 29
#> 3 VC median 16.5 29
#> 4 VC q1 11.2 29
#> 5 VC q3 23.3 29
#> 6 VC min 4.2 29
#> 7 VC max 33.9 29
#> 8 OJ mean 20.7 29
#> 9 OJ sd 6.72 29
#> 10 OJ median 23 29
#> 11 OJ q1 15.2 29
#> 12 OJ q3 25.8 29
#> 13 OJ min 8.2 29
#> 14 OJ max 30.9 29
try(report_descriptive(stored, group = "supp"))
#> Error : selection/label arguments apply only to raw-data descriptionsA prespecified test can be shown next to the descriptive rows. It is computed separately, here on the complete cases, and joined only through explicit identifiers: the variable, the result and the result row. Display labels are never used for matching, and the analysis population of the test must be named.
complete <- !is.na(tg$len)
len_test <- run_inference(method_spec("t_means_two_independent_welch"),
x = tg$len[complete & tg$supp == "OJ"],
y = tg$len[complete & tg$supp == "VC"],
result_id = "len-oj-vs-vc")
mapping <- data.frame(
variable_id = "len",
result_id = "len-oj-vs-vc",
row_id = result_data(len_test)$row_id
)
joined <- report_descriptive(tg, group = "supp",
labels = c(len = "Odontoblast length", dose = "Daily dose"),
units = c(dose = "mg/day"),
inference = len_test, mapping = mapping,
inference_population = "Complete cases; OJ minus VC")
joined[joined$estimand == "mean",
c("group", "label", "estimate_display", "n", "inference_p_display",
"inference_n", "inference_population")]
#> group label estimate_display n inference_p_display inference_n
#> 1 VC Odontoblast length 17.3 29 p = 0.090 58
#> 11 OJ Odontoblast length 20.7 29 p = 0.090 58
#> inference_population
#> 1 Complete cases; OJ minus VC
#> 11 Complete cases; OJ minus VCAll joined fields carry the prefix inference_. At most
one inference row can be attached to each variable. The metadata keeps
the descriptive and the inferential population separately:
This package is part of an inference suite (infercalcR, inferguidR and infereportR) that is deeply inspired by DescrTab2 [1], developed at the Institute of Medical Biometry (IMBI), Heidelberg University, by Jan Meis, Lukas Baumann, Maximilian Pilz and Lukas Sauer. Its test-choice tree, its validation statement and its practice of computing each test with an established implementation are the model for how the suite chooses, computes and reports statistical tests. DescrTab2 was archived on CRAN on 18 October 2025; its source code remains available on GitHub. The methods-consulting pages of the University of Zurich [2], with their decision tree, decision assistant, worked examples and explanations, inspired the guidance in the suite. Power and sample-size planning and the distribution calculator follow G*Power 3.1 [3, 4]. We thank the authors of these works for making them openly available. The package README cites all software the package uses.