Skip to content

Add add_label_column() to split labels into a value column - #315

Merged
Melkiades merged 2 commits into
mainfrom
modify_value_column@main
Sep 4, 2026
Merged

Add add_label_column() to split labels into a value column#315
Melkiades merged 2 commits into
mainfrom
modify_value_column@main

Conversation

@Melkiades

@Melkiades Melkiades commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

What changes are proposed in this pull request?

This is the strata_location = "new_column" layout of tbl_shift() extracted into a standalone, exported helper so nested count and shift tables can reuse it instead of hand-rolling modify_table_body() + alignment + indent + header. tbl_shift() now calls the helper; its output is unchanged (snapshots identical).

The helper adds two options tbl_shift() did not need, so nested count tables (e.g. LBT05 in {tlg.templates}) can adopt it: .after to place the value column on either side of label, and indent = NULL to preserve an existing nested indentation. The API is intentionally strict for now and can grow as more templates adopt it.

Reference GitHub issue associated with pull request. closes #314


Pre-review Checklist (if item does not apply, mark is as complete)

  • All GitHub Action workflows pass with a ✅
  • PR branch has pulled the most recent updates from master branch: usethis::pr_merge_main()
  • If a bug was fixed, a unit test was added.
  • Code coverage is suitable for any new functions/features (generally, 100% coverage for new code): devtools::test_coverage()
  • Request a reviewer

@Melkiades
Melkiades marked this pull request as ready for review September 2, 2026 11:45
Comment thread R/add_label_column.R
Comment thread R/modify_value_column.R Outdated
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

badge

Code Coverage Summary

Filename                                 Stmts    Miss  Cover    Missing
-------------------------------------  -------  ------  -------  ------------------------------------------------------------------------------------------------
R/add_blank_rows.R                          63       0  100.00%
R/add_difference_row.R                     101       0  100.00%
R/add_forest_utils.R                        97      10  89.69%   76-79, 94-100
R/add_forest.R                             139       0  100.00%
R/add_hierarchical_count_row.R              33       0  100.00%
R/add_label_column.R                        26       0  100.00%
R/adjust_stat_columns_wrap.R                29       1  96.55%   59
R/annotate_gg_km.R                         141       0  100.00%
R/annotate_gg_pkc.R                        100       0  100.00%
R/annotate_gg.R                             94       0  100.00%
R/ard_tabulate_abnormal_by_baseline.R       65       0  100.00%
R/crane-package.R                            2       2  0.00%    26-27
R/deprecated.R                              21      21  0.00%    18-54
R/df_add_poolings.R                         41       0  100.00%
R/get_cox_pairwise_df.R                    163       0  100.00%
R/gg_km_utils.R                             39      14  64.10%   20-37
R/gg_km.R                                  143      37  74.13%   55-58, 75, 102, 176-181, 184-187, 197-199, 204-205, 239-241, 248-251, 255, 266-270, 283, 285-287
R/gg_lineplot.R                            121       0  100.00%
R/gg_mmrm_lineplot.R                       102       1  99.02%   106
R/gg_pkc_lineplot.R                         98       0  100.00%
R/gg_utils.R                               222       0  100.00%
R/label_roche.R                             72       0  100.00%
R/modify_header_rm_md.R                     18       2  88.89%   35-36
R/modify_split_caption.R                    26       0  100.00%
R/modify_zero_recode.R                      20       1  95.00%   64
R/pk_helper.R                              499       0  100.00%
R/reverse_difference_ci.R                   33       0  100.00%
R/tbl_baseline_chg.R                       188       0  100.00%
R/tbl_coxph.R                               90       1  98.89%   229
R/tbl_hierarchical_incidence_rate.R        291       4  98.63%   430-433
R/tbl_hierarchical_rate_and_count.R        339      13  96.17%   343, 425, 446-456
R/tbl_hierarchical_rate_by_grade.R         317       3  99.05%   169-171
R/tbl_listing.R                             36       0  100.00%
R/tbl_mmrm.R                               344       6  98.26%   452-456, 548
R/tbl_null_report.R                         10       0  100.00%
R/tbl_rmpt.R                               157      12  92.36%   299-304, 316-321
R/tbl_roche_subgroups.R                    157       0  100.00%
R/tbl_roche_summary.R                       64       0  100.00%
R/tbl_shift.R                              111       0  100.00%
R/tbl_survfit_quantiles.R                  154       0  100.00%
R/tbl_survfit_times.R                       92       0  100.00%
R/tbl_with_pools.R                          79       1  98.73%   317
R/theme_gtsummary_roche.R                   87       1  98.85%   61
R/utils.R                                   42       0  100.00%
TOTAL                                     5066     130  97.43%

Diff against main

Filename                Stmts    Miss  Cover
--------------------  -------  ------  --------
R/add_label_column.R      +26       0  +100.00%
R/tbl_shift.R              -5       0  +100.00%
TOTAL                     +21       0  +0.01%

Results for commit: 93e2244

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Unit Tests Summary

  1 files  314 suites   1m 51s ⏱️
314 tests 314 ✅ 0 💤 0 ❌
912 runs  912 ✅ 0 💤 0 ❌

Results for commit 93e2244.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Unit Test Performance Difference

Test Suite $Status$ Time on main $±Time$ $±Tests$ $±Skipped$ $±Failures$ $±Errors$
add_label_column 👶 $+0.00$ $+3$ $0$ $0$ $0$
Additional test case details
Test Suite $Status$ Time on main $±Time$ Test Case
add_forest 💚 $6.47$ $-3.36$ add_forest_table_engine_flextable_works
add_label_column 👶 $+0.00$ add_label_column_can_place_the_value_column_after_label
add_label_column 👶 $+0.00$ add_label_column_checks_inputs
add_label_column 👶 $+0.00$ add_label_column_default_header_is_Value_and_label_unchanged
add_label_column 👶 $+0.00$ add_label_column_indent_NULL_leaves_label_indentation_untouched
add_label_column 👶 $+1.71$ add_label_column_inserts_label0_before_label
add_label_column 👶 $+0.00$ add_label_column_sets_headers_alignment_and_indent
annotate_gg_km 💔 $1.76$ $+1.42$ annotate_riskdf_handles_all_branches_and_inputs
tbl_hierarchical_incidence_rate 💚 $8.51$ $-1.33$ tbl_hierarchical_incidence_rate_runs_with_minimum_arguments
tbl_mmrm 💚 $2.12$ $-2.08$ se_calculates_standard_error_correctly
tbl_rmpt 💔 $5.89$ $+1.92$ tbl_rmpt_works_with_default_parameters_Example_1_
tbl_roche_subgroups 💚 $5.74$ $-2.53$ tbl_roche_subgroups_time_to_event_NULL_works
tbl_shift 💚 $3.99$ $-2.53$ tbl_shift_strata_location_
tbl_survfit_quantiles 💔 $0.62$ $+3.73$ tbl_survfit_quantiles_works

Results for commit 96726ce

♻️ This comment has been updated with latest results.

@Melkiades
Melkiades force-pushed the modify_value_column@main branch 2 times, most recently from b57b58e to a6724b2 Compare September 2, 2026 12:00
Comment thread R/tbl_shift.R Outdated
Extract the "value column" layout from tbl_shift(strata_location =
"new_column") into a standalone exported helper. It adds a new label0
column from an expression evaluated in the table body, then handles
alignment, indentation, and headers.

The helper adds two options tbl_shift did not need so nested count
tables (e.g. LBT05 in tlg.templates) can reuse it: `.after` to place
the new column on either side of label, and `indent = NULL` to keep
an existing nested indentation. tbl_shift now calls the helper; its
output is unchanged.

closes #314
@Melkiades
Melkiades force-pushed the modify_value_column@main branch from a6724b2 to c7296f0 Compare September 3, 2026 14:29
@Melkiades Melkiades changed the title Add modify_value_column() to split labels into a value column Add add_label_column() to split labels into a value column Sep 3, 2026
Give the add_label_column() branch a higher version than main so
dependents pin it via the version constraint and dependency resolvers
install this branch instead of a cached same-version crane.
@wzfrank
wzfrank self-requested a review September 3, 2026 18:54

@wzfrank wzfrank left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good. Thank you!

@Melkiades
Melkiades merged commit 198933c into main Sep 4, 2026
34 checks passed
@Melkiades
Melkiades deleted the modify_value_column@main branch September 4, 2026 13:38
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Add add_label_column() to split row labels into a new label column

2 participants