Skip to content

Add pk helper functions - #289

Open
qiliu1013 wants to merge 5 commits into
mainfrom
287_pk_helper
Open

Add pk helper functions#289
qiliu1013 wants to merge 5 commits into
mainfrom
287_pk_helper

Conversation

@qiliu1013

Copy link
Copy Markdown
Collaborator

What changes are proposed in this pull request?

  • Style this entry in a way that can be copied directly into NEWS.md. (#, @)

Provide more detail here as needed.

Add cv(), geom_cv(), geom_mean(), fmt_3sig() and impuation_rules for the PK TLGs.

Close #287


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

Reviewer Checklist (if item does not apply, mark is as complete)

  • If a bug was fixed, a unit test was added.
  • Run pkgdown::build_site(). Check the R console for errors, and review the rendered website.
  • Code coverage is suitable for any new functions/features: devtools::test_coverage()

When the branch is ready to be merged:

  • Update NEWS.md with the changes from this pull request under the heading "# cards (development version)". If there is an issue associated with the pull request, reference it in parentheses at the end update (see NEWS.md for examples).
  • All GitHub Action workflows pass with a ✅
  • Approve Pull Request
  • Merge the PR. Please use "Squash and merge" or "Rebase and merge".

@qiliu1013
qiliu1013 requested a review from shajoezhu July 23, 2026 20:27
@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

✅ All contributors have signed the CLA
Posted by the CLA Assistant Lite bot.

@qiliu1013
qiliu1013 requested a review from wzfrank July 23, 2026 20:29
@qiliu1013

Copy link
Copy Markdown
Collaborator Author

Hi @shajoezhu @wzfrank,

Could you please help with the tests on the functions? Is there a certain format I need to follow? So some simple tests below are fine.

`
test_that("cv() works", {
expect_equal(cv(c(1, 2, 3, 4, 5)), 52.70463, tolerance = 1e-4)
expect_true(is.na(cv(c(NA, NA))))
})

test_that("geom_mean() returns NA for non-positive values", {
expect_equal(geom_mean(c(1, 2, 4)), exp(mean(log(c(1, 2, 4)))))
expect_true(is.na(geom_mean(c(1, -1, 3))))
})

test_that("fmt_3sig() formats correctly", {
expect_equal(fmt_3sig(0.001234), "0.00123")
expect_equal(fmt_3sig(NA), NA_character_)
})
`

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Unit Tests Summary

  1 files  260 suites   2m 15s ⏱️
260 tests 260 ✅ 0 💤 0 ❌
760 runs  760 ✅ 0 💤 0 ❌

Results for commit 8dbb153.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Unit Test Performance Difference

Additional test case details
Test Suite $Status$ Time on main $±Time$ Test Case
add_blank_rows 💚 $5.96$ $-1.42$ add_blank_rows_works
add_grade_column 💚 $18.40$ $-4.76$ add_grade_column_works_on_a_standalone_tbl_hierarchical_rate_by_grade
annotate_gg_pkc 💚 $2.76$ $-2.66$ annotate_pkc_df_warns_when_given_a_standard_ggplot_object
gg_km 💔 $0.25$ $+1.99$ gg_km_works_and_handles_annotations_correctly
tbl_baseline_chg 💚 $18.64$ $-4.96$ tbl_baseline_chg_works
tbl_hierarchical_incidence_rate 💚 $15.04$ $-1.96$ tbl_hierarchical_incidence_rate_runs_with_minimum_arguments
tbl_hierarchical_rate_and_count 💚 $22.29$ $-5.71$ tbl_hierarchical_rate_and_count_works
tbl_hierarchical_rate_by_grade 💚 $18.37$ $-7.66$ tbl_hierarchical_rate_by_grade_works
tbl_mmrm 💚 $5.89$ $-1.49$ se_calculates_standard_error_correctly
tbl_rmpt 💚 $12.54$ $-3.10$ tbl_rmpt_works_with_default_parameters_Example_1_
tbl_roche_subgroups 💚 $3.31$ $-1.80$ tbl_roche_subgroups_time_to_event_NULL_works
tbl_roche_summary 💔 $2.56$ $+1.54$ tbl_roche_summary_works
tbl_survfit_quantiles 💚 $5.77$ $-1.51$ tbl_survfit_quantiles_works
tbl_with_pools 💚 $9.73$ $-2.78$ tbl_with_pools_validates_inputs_correctly
theme_gtsummary_roche 💚 $6.34$ $-1.67$ theme_gtsummary_roche_works

Results for commit 408ec74

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Jul 23, 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/adjust_stat_columns_wrap.R                29       1  96.55%   59
R/annotate_gg_km.R                         141       0  100.00%
R/annotate_gg_pkc.R                         92       0  100.00%
R/annotate_gg.R                             81       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                             94       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_zero_recode.R                      20       1  95.00%   64
R/pk_helper.R                               30      30  0.00%    14-125
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                             35       0  100.00%
R/tbl_mmrm.R                               254       1  99.61%   393
R/tbl_null_report.R                          9       0  100.00%
R/tbl_rmpt.R                               157      12  92.36%   299-304, 316-321
R/tbl_roche_subgroups.R                    155       0  100.00%
R/tbl_roche_summary.R                       64       0  100.00%
R/tbl_shift.R                              116       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                          64       0  100.00%
R/theme_gtsummary_roche.R                   87       1  98.85%   61
R/utils.R                                   42       0  100.00%
TOTAL                                     4393     154  96.49%

Diff against main

Filename         Stmts    Miss  Cover
-------------  -------  ------  --------
R/pk_helper.R      +30     +30  +100.00%
TOTAL              +30     +30  -0.66%

Results for commit: 8dbb153

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@qiliu1013
qiliu1013 requested a review from mhallal1 August 6, 2026 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add function for 3 sig figures to fix the issue in gtsummary::label_style_sigfig(3)

2 participants