Clinical-reporting vignettes should use an explicit rounding policy
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 85
- Forks
- 23
- PR merge metrics
- No merged PRs in 30d
Description
Problem
The executable clinical-reporting vignettes use base round() and formatC(..., format = "f") directly for percentages and summary statistics. Under a SAS-compatible, ties-away-from-zero reporting policy, these calls can display the wrong value at ties.
This is not a request to change RTF layout/geometry rounding. It is limited to examples that calculate or render clinical-style report statistics.
Reproduced on current master
- Commit:
8d7b4adc69db750a639b9129290be4818916717e - R: 4.5.3
formatC(1.25, format = "f", digits = 1) # "1.2"
round(1.25, 1) # 1.2
For the intended ties-away policy, both values should be 1.3; likewise -1.25 should become -1.3. Decimal examples also depend on binary representation, so a solution must be tested with exact and inexact decimal ties rather than assuming that formatC() has a single tie mode.
Affected reporting paths
vignettes/example-basechar.Rmd:56,91-93,103-105— percentage, mean, SD, and median display withformatC().vignettes/example-efficacy.Rmd:40,42,55-56,69,156—fmt_est,fmt_ci, andfmt_pvaldisplay estimates, confidence intervals, p-values, and residual SD withformatC().vignettes/example-ae-summary.Rmd:39— AE percentage calculation usesround(..., 2).vignettes/rtf-row.Rmd:143— executable table example usesformatC().
The package's inch-to-twip, font-size, pagination, and cell-geometry calculations are intentionally out of scope.
Requested change
Make the reporting vignettes use one explicit, documented rounding policy before fixed-width display. Keep calculations unrounded until the final display step; then apply a ties-away-from-zero helper at the required digits and render with a fixed-width formatter such as formatC(..., format = "f", digits = ...).
The implementation may use a versioned dependency or a small documented helper, but it should not add a hidden policy change to generic RTF layout code. If the project does not intend these vignettes to promise SAS-compatible rounding, document that limitation prominently instead of silently relying on base R behavior.
Acceptance criteria
- Reporting examples use an explicit and documented rounding policy at their display boundaries; generic RTF layout/encoding code remains unchanged.
- At one decimal, positive and negative exact ties use ties-away behavior:
1.25 -> "1.3"and-1.25 -> "-1.3". - Tests cover representative decimal ties that expose binary-representation effects, not only
x.5at zero decimals. - Values that round to zero never render as
"-0"or"-0.0". - Fixed-width display is retained where the vignette requests it (for example,
76 -> "76.00"at two decimals). - Summary statistics are calculated from unrounded inputs and rounded only when prepared for display.
- Affected vignettes render successfully after the change.
Audit evidence
The repository-root audit scanned 57 supported reporting files (45 .R, 12 .Rmd) and inventoried 421 candidates. The Rounding Skill probe completed 7/7 invariants in the audit environment. The detailed audit record is available at https://github.com/RConsortium/pharma-skills/issues/174#issuecomment-5577387523.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the affected executable vignettes: vignettes/example-basechar.Rmd, example-efficacy.Rmd, example-ae-summary.Rmd, and rtf-row.Rmd. First reproduce the supplied R tie examples, then inspect each reporting display boundary and verify the acceptance cases, including negative ties, decimal representation effects, fixed-width output, unrounded summaries, and successful vignette rendering.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- documentation, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100