Skip to content

Solve issue #223 - #224

Merged
LittleBeannie merged 5 commits into
mainfrom
223-issue-in-format_ae_summary
Jul 30, 2026
Merged

Solve issue #223#224
LittleBeannie merged 5 commits into
mainfrom
223-issue-in-format_ae_summary

Conversation

@LittleBeannie

@LittleBeannie LittleBeannie commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

The original implementation was only an alias:

format_ae_summary <- format_ae_specific

That worked when every AE parameter had a predefined summ_row, but issue 223 introduced a custom parameter:
This parameter had a label, but no summ_row.

Root Cause

prepare_ae_summary() produced:

Five rows in outdata$n: population, any AE, no AE, drug-related AE, and drug-related death.
Only four values in outdata$name, because the missing summ_row for drug-related was discarded by unlist().
When format_ae_specific() tried to combine the five formatted rows with four row names, R raised:

rguments imply differing number of rows: 4, 5

Why The New Logic Works

In prepare_ae_summary.R, the function first detects the inconsistency:
It only repairs names when necessary, so existing valid summary outputs are unchanged.
For each requested parameter, it uses the standard summary text when available and otherwise falls back to the user-provided label:

Therefore:

  • any uses "with one or more adverse events".
  • Custom drug-related uses "Drug-related AEs".
  • dtc0rel uses "who died due to a drug-related adverse event".
  • The special "with no adverse events" row is added because prepare_ae_summary() creates an additional numeric row for it whenever any is requested.

Finally, the function delegates to format_ae_specific() for the actual numeric and percentage formatting. The full argument list is retained so format_ae_summary() preserves its existing API, defaults, documentation, and named-argument behavior.

This approach was chosen because the issue specifically requested changing only format_ae_summary(). Architecturally, the name mismatch originates during preparation, but the wrapper repairs that mismatch without modifying prepare_ae_summary() or the shared formatter.

@LittleBeannie LittleBeannie self-assigned this Jul 27, 2026
@LittleBeannie LittleBeannie linked an issue Jul 27, 2026 that may be closed by this pull request

@fukuhiro2023 fukuhiro2023 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.

looks good to me

@LittleBeannie
LittleBeannie merged commit 04c9d81 into main Jul 30, 2026
7 checks passed
@LittleBeannie
LittleBeannie deleted the 223-issue-in-format_ae_summary branch July 30, 2026 15:31
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.

Issue in format_ae_summary

2 participants