The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Some extras for gtsummary tables
sumExtras provides convenience functions for gtsummary and gt tables, including automatic variable labeling from dictionaries, standardized missing value display, and consistent formatting helpers for streamlined table styling workflows.
install.packages("sumExtras")You can install the development version of sumExtras from GitHub:
# install.packages("pak")
pak::pak("kyleGrealis/sumExtras")Alternatively, using remotes:
# install.packages("remotes")
remotes::install_github("kyleGrealis/sumExtras")my_table <- trial |>
mutate(
stage = case_when(
trt == 'Drug A' & stage == 'T2' ~ NA,
trt == 'Drug B' & stage == 'T4' ~ NA,
.default = stage
)
) |>
select(age, marker, grade, stage, trt) |
Basic gtsummary
|
sumExtras with Advanced Styling
|
|
|
The basic approach creates a functional table, but sumExtras makes it shine with group headers, custom formatting, background colors, and clean missing value display—all while maintaining readable code. The right example shows what’s possible when you need publication-ready tables.
library(sumExtras)
library(gtsummary)
# Apply the recommended JAMA theme (optional but recommended)
use_jama_theme()
# The extras() function - does it all!
trial |>
tbl_summary(by = trt) |>
extras() # Adds overall, p-values, cleans missing values, and more!
# Clean missing values independently
trial |>
tbl_summary(by = trt) |>
clean_table() # Standardizes missing/zero displays to "---"
# With automatic labels from your dictionary
# First, create a dictionary with Variable and Description columns
dictionary <- tibble::tribble(
~Variable, ~Description,
"age", "Age at Enrollment",
"marker", "Marker Level (ng/mL)",
"trt", "Treatment Group",
"grade", "Tumor Grade"
)
trial |>
tbl_summary(by = trt) |>
add_auto_labels() |> # Automatically finds 'dictionary' in your environment
extras()extras() - The signature function that adds overall
columns, p-values, and clean stylingclean_table() - Standardizes missing value displayadd_auto_labels() - Smart automatic variable labeling
from dictionaries or label attributesapply_labels_from_dictionary() - Set label attributes
on data for cross-package workflows (ggplot2, gt, etc.)use_jama_theme() - Apply JAMA compact theme to
gtsummary tablestheme_gt_compact() - JAMA-style compact themes for gt
tablesadd_group_styling() - Enhanced text formatting for
grouped tables with customizable indentationadd_group_colors() - Convenience function for group
colors with automatic gt conversionget_group_rows() - Extract group row information from
grouped tablesThe labeling functions use the same native R attribute approach as
popular packages like haven, Hmisc,
and ggplot2 4.0+. Labels are stored as simple
'label' attributes on data columns—no special packages or
formats required.
Your data may already have labels from various sources:
- Imported datasets (haven reads SPSS/Stata/SAS labels
automatically)
- Other packages that set label attributes
- Manual labeling with
attr(data$column, "label") <- "Label"
- Collaborative projects with pre-labeled data
The add_auto_labels() function intelligently reads both
dictionary-based labels and existing label attributes from your data,
letting you choose which takes precedence. Labels work seamlessly across
the entire R ecosystem—compatible with gtsummary,
ggplot2, gt, and other label-aware
packages.
The extras() function is designed to work with all
gtsummary table types using a “warn-and-continue” philosophy:
* It applies all compatible features to your table
* For unsupported features, it issues a helpful warning and continues
with what works
* The function always succeeds - it never breaks your
pipeline
| Table Type | bold_labels | modify_header | add_overall | add_p | Status |
|---|---|---|---|---|---|
| tbl_summary (stratified) | ✅ | ✅ | ✅ | ✅ | Full support |
| tbl_summary (unstratified) | ✅ | ✅ | ⚠️ | ⚠️ | Partial support |
| tbl_svysummary (stratified) | ✅ | ✅ | ✅ | ✅ | Full support |
| tbl_regression | ✅ | ✅ | ⚠️ | ⚠️ | Partial support |
| tbl_strata | ✅ | ✅ | ⚠️ | ⚠️ | Partial support |
Legend:
* ✅ Feature works and is applied
* ⚠️ Feature not applicable to this table type (function warns but
continues)
When you call extras() on any table:
Example with an unstratified table:
trial |>
tbl_summary() |> # No 'by' argument = unstratified
extras() # Warns that overall/p-values aren't supported, but still bolds labels and cleans headersYou’ll see a warning like: “This table is not stratified. Overall column and p-values require stratification. Applying only bold_labels() and modify_header().” but your table is still successfully formatted!
sumExtras = “SUMmary table EXTRAS” + “SOME EXTRAS for gtSUMMARY”
Get it?
vignette("sumExtras-intro")?extras?clean_table?add_auto_labels?add_group_styling?add_group_colors?use_jama_themeexample(extras) for
quick demossumExtras is thoroughly tested with:
test-extras.R,
test-extras-warnings.R)test-clean_table.R,
test-clean_table-regex.R)test-labels.R) - 51 tests covering:
test-use_jama_theme.R)test-styling.R)All tests pass with 100% success rate. See the tests directory for detailed test examples and patterns.
We’re constantly improving sumExtras. Upcoming feature considerations include:
We welcome contributions and ideas! Here’s how you can help:
sumExtras is licensed under the MIT License. See the LICENSE file for details.
sumExtras is built with love using R and these amazing packages:
sumExtras adds some extras to your summary tables! ✨
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.