Merck / Merck/metalite

collect_n_subject() should use an explicit rounding policy at display boundaries

Open
#184 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
18
Forks
8
PR merge metrics
No merged PRs in 30d

Description

Rounding compliance report -- Merck/metalite 0.1.4

Target: Merck/metalite at 85757ba1bf5d863971e142b7872b6f92c265d6ef
Environment: R 4.5.3 (2026-03-11)
Policy: Rounding Skill BR-001/002/003 v1.0: SAS-compatible ties-away-from-zero, round once at display, fixed trailing-zero precision. The target repository's rule owner is unassigned.
Display inference: collect_n_subject() defaults decimal_places_summary = 1 and decimal_places_percent = 1 at R/collect_n_subject.R:156-157; literal formatC(..., format = "f", digits = ...) calls at :248, :263, and :304 make one decimal with trailing zeros the contextual expectation.
Status: Fix-ready target-repository handoff. Read-only audit; no source was changed.
Verdict: FAIL under the supplied BR-001 policy. collect_n_subject() formats unrounded statistics and percentages with base formatC(), which diverges at ties. BR-002 and BR-003 are PASS for the traced sites under the recorded display inference.

Summary

# Site Entry path Tie Stage Display Overall Witness (before → after)
1 R/collect_n_subject.R:248 formatC(value, ...) exported collect_n_subject() numeric summaries FAIL PASS PASS FAIL 1.25: 1.21.3; -1.25: -1.2-1.3 at 1 dp
2 R/collect_n_subject.R:263 formatC(pop_n / pop_all * 100, ...) exported collect_n_subject() numeric-variable percentages FAIL PASS PASS FAIL 1 / 16 * 100 = 6.25: 6.26.3 at 1 dp
3 R/collect_n_subject.R:304 formatC(pop_tmp / pop_all * 100, ...) exported collect_n_subject() categorical-variable percentages FAIL PASS PASS FAIL Same percentage display operation and witness as row 2

Fix (advisory): preserve unrounded statistics, apply the selected versioned ties-away numeric helper once at the final display boundary, normalize zero, then use formatC(..., format = "f", digits = ...) for the approved fixed-width string.

Appendix A. Coverage

  • Scanner v2.1 covered 33 supported reporting files from the repository root: R=28 Rmd=5. The source inventory was 56 .R, 5 .Rmd, 0 .qmd, and 0 .Rnw files.
  • Scanner totals: 135 candidates: 0 quantize, 6 display, 0 quantizing operators, and 129 wrappers. The three in-scope display boundaries are the formatC() calls at R/collect_n_subject.R:248, :263, and :304.
  • All five .Rmd files were included in coverage. vignettes/mockup-table.Rmd uses placeholder strings ("x", "x.xx") rather than numeric rounding, so it has no in-scope numeric operation.
  • Excluded, never scored: R/adam_mapping.R:151 metadata print formatting; identifier/level conversion via as.character(); data-raw and metadata-builder wrapper paths; and test assertions. These do not quantize or fix numeric report statistics.

Appendix B. Evidence (executed)

Before: base formatting at the site precision:

summary_positive_tie: input=1.25 digits=1 actual=1.2 policy=1.3
summary_negative_tie: input=-1.25 digits=1 actual=-1.2 policy=-1.3
percent_count_ratio: input=6.25 digits=1 actual=6.2 policy=6.3
negative_zero: input=-0.04 digits=1 actual=-0.0 policy=0.0

After: dependency-free ties-away arithmetic, followed by fixed-width formatting, produced 1.3, -1.3, 6.3, and 0.0 respectively. This demonstrates the required fix pattern; select and version the production helper before implementation.

The three source calls occur after mean, sd, median, min, max, quantile, or percentage calculation. The traced paths do not round an input before later aggregation or a threshold decision, supporting the BR-002 PASS. The negative summary value can render as "-0.0", which is part of the BR-001 failure under the supplied policy.

Appendix C. Limitations

  • No target-owned rounding policy, selected helper/version, or named rule owner was supplied. The FAIL is conditional on the supplied SAS-compatible policy.
  • Display digits and trailing zeros were inferred from the collect_n_subject() one-decimal defaults and its fixed-width formatC() calls; an explicit specification would supersede that contextual inference.
  • Blind spots: dynamic dispatch (do.call, get, match.fun), dependency internals, and runtime-created format strings.
  • metalite is metadata/reporting infrastructure; downstream packages may add display behavior outside this repository.

Decisions Required (for the rule owner)

  1. Confirm whether SAS-compatible ties-away-from-zero is required for collect_n_subject() outputs.
  2. Select and version the helper to apply at the three display boundaries, including signed-zero normalization.
  3. Confirm or replace the inferred one-decimal, trailing-zero display expectation for summaries and percentages.

Target issue handoff

This issue is the authorized handoff for the single defect cluster above. Acceptance criteria:

  • Positive and negative one-decimal ties display away from zero: 1.25 -> "1.3", -1.25 -> "-1.3".
  • A representative decimal percentage tie, such as 1 / 16 * 100, displays "6.3" at one decimal.
  • Values that round to zero never render as "-0" or "-0.0".
  • Calculations remain unrounded until their final display boundary.
  • Fixed-width one-decimal rendering remains in place unless an approved specification replaces the recorded inference.
  • Generic metadata, RTF layout, and encoding code remain unchanged.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in R/collect_n_subject.R at the formatC() calls on lines 248, 263, and 304, and review the one-decimal defaults at lines 156-157. Confirm the rounding policy, helper version, and display precision with the rule owner before changing the three display boundaries. Done means ties display away from zero, signed zero is normalized, calculations remain unrounded until display, and the listed acceptance examples pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.