Repository navigation
Add overall_row, ARD structure checks, and attribute labels to tbl_ard_hierarchical() - #2489
Merged
Merged
Conversation
…_ard_hierarchical()` (#2021) - New `overall_row` argument uses the `..ard_hierarchical_overall..` results from `over_variables = TRUE`; previously these rows were silently dropped. - Check the ARD structure against `variables`, `by`, `include`, and `statistic`; some mismatches previously returned an incomplete table. - Default labels now come from the ARD's label attributes, and `label` accepts formula-list-selector syntax as documented. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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?
tbl_ard_hierarchical(): (tbl_hierarchical()enhancements #2021)overall_rowargument to include an overall summary row at the top of the table, using results fromcards::ard_stack_hierarchical(over_variables = TRUE)orcards::ard_stack_hierarchical_count(over_variables = TRUE).cardsinput is now checked against thevariables,by,include, andstatisticarguments, and an informative error is returned when they do not match. Previously, some mismatches silently returned an incomplete table.cards::ard_stack_hierarchical(attributes = TRUE)), and thelabelargument now accepts formula-list-selector syntax, as documented.Notes for the reviewer
tbl_hierarchical()enhancements #2021. The open question in that issue (should the hierarchical ARD functions optionally include the data frame attributes?) is already handled in cards 0.9.0 viaattributes = TRUE. The gtsummary side, using those attributes as the default labels, is done here.overall_row = FALSEwas hard-coded in the bridge call. A label for the overall row could also never be applied, because the code looked up an"overall"name instead of"..ard_hierarchical_overall..".include = everything(), an ARD built withinclude = AETERMreturned a table missing every SOC row.c(by, <preceding hierarchy variables>), in order. The non-standardard_tabulate()ARD in the existing tests passes this check.overall_row = TRUEoutput is identical totbl_hierarchical()andtbl_hierarchical_count(). Each new error message is covered by a snapshot.perfprefix.If there is an GitHub issue associated with this pull request, please provide link.
closes #2021
Reviewer Checklist (if item does not apply, mark is as complete)
devtools::test_coverage()spelling::spell_check_package()runs with no spelling errors in documentationNEWS.mdwith the changes from this pull request under the heading "# gtsummary (development version)". If there is an issue associated with the pull request, reference it in parentheses at the end update (seeNEWS.mdfor examples).When the branch is ready to be merged into master:
🤖 Generated with Claude Code