Add modify_split_caption() to label paginated splits and hide the split column (#282)#283
Open
Melkiades wants to merge 8 commits into
Open
Add modify_split_caption() to label paginated splits and hide the split column (#282)#283Melkiades wants to merge 8 commits into
Melkiades wants to merge 8 commits into
Conversation
…282) Post-process a tbl_split listing so each page carries a caption built from its split level via a glue pattern (default 'Parameter: {spl_level}', suited to lab listings split by PARAM) and the now-redundant split column is hidden. - Operates on a single split element or the whole list. - Keeps the gtsummary-native variable_level attribute in sync so decorators that read it show the same caption. - Hiding is silent when the column is absent or already hidden; pages from row-number splits (no variable_level) are skipped. Co-located in R/tbl_listing.R under @Rdname tbl_listing with remove_duplicate_keys().
Contributor
Unit Tests Summary 1 files 267 suites 3m 30s ⏱️ Results for commit 213b972. ♻️ This comment has been updated with latest results. |
Contributor
Unit Test Performance Difference
Additional test case details
Results for commit 62e61af ♻️ This comment has been updated with latest results. |
Contributor
Code Coverage SummaryDiff against mainResults for commit: 213b972 Minimum allowed coverage is ♻️ This comment has been updated with latest results |
Move modify_split_caption() out of the tbl_listing help page into its
own R/modify_split_caption.R with a standalone doc page, since it applies
to any split {gtsummary} table, not just listings. Add @Seealso
cross-links and usage examples to the commonly-split tbl_* functions
(tbl_listing, tbl_baseline_chg, tbl_shift) and move its tests to a
dedicated test-modify_split_caption.R.
llrs-roche
reviewed
Jul 2, 2026
Co-authored-by: Lluís Revilla <185338939+llrs-roche@users.noreply.github.com> Signed-off-by: Davide Garolini <dgarolini@gmail.com>
- move argument checks above the list map so a list of split tables is validated once up front - use all(spl_col %in% ...) in the hide condition, matching all_of() below - shorten and focus the examples on the new function - assert caption, variable_level and hide flag on every page
Contributor
Author
|
On the centered caption: that's the renderer's default, not something this function sets -- we just call |
llrs-roche
approved these changes
Jul 3, 2026
Writing both a caption and the variable_level subtitle duplicated the text after decoration with citril::decorate_tlg(). Set only the native variable_level attribute so decorators render it once as a page subtitle.
Set the split label as a gtsummary caption in addition to the variable_level attribute. The caption renders inside the table's <caption> element so the subtitle is visible when a split page is printed on its own, while variable_level lets reporting engines promote the same text to a dedicated subtitle row.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What changes are proposed in this pull request?
modify_split_caption()to label each page of a split listing from its split level (via a gluepattern, default"Parameter: {spl_level}") and hide the now-redundant split column. (Add modify_split_caption() to label paginated splits and hide the split column #282, @Melkiades)When a listing is paginated with
gtsummary::tbl_split_by_rows(variable_level = <col>)(e.g. a lab listing split byPARAM, or a demographics listing split by treatment), two post-processing steps were previously repeated inline in every template: prefixing the split level for the page caption/subtitle, and hiding the redundant split column.modify_split_caption()bundles both:patternis a single glue string ({spl_level}is the split value); default suits BDS/lab tables.hide_spl_col = TRUEby default; silent when the column is absent or already hidden.tbl_splitlist; row-number splits (novariable_level) are skipped.variable_levelattribute in sync with the caption, so decorators that read it (e.g. citril) show the same text — no external dependency added.Co-located in
R/tbl_listing.Runder@rdname tbl_listing, next toremove_duplicate_keys().Reference GitHub issue associated with pull request. closes #282
Pre-review Checklist (if item does not apply, mark is as complete)
usethis::pr_merge_main()devtools::test_coverage()Reviewer Checklist (if item does not apply, mark is as complete)
pkgdown::build_site(). Check the R console for errors, and review the rendered website.devtools::test_coverage()When the branch is ready to be merged:
NEWS.mdwith the changes from this pull request under the heading "# crane (development version)". If there is an issue associated with the pull request, reference it in parentheses at the end update (seeNEWS.mdfor examples).