Skip to content

Fix summarize_ancova() contrasts for arm levels with regex metacharacters (#1471) - #1540

Open
gwangjinkim wants to merge 1 commit into
pharmaverse:mainfrom
gwangjinkim:fix/1471-ancova-regex-escape
Open

gwangjinkim wants to merge 1 commit into
pharmaverse:mainfrom
gwangjinkim:fix/1471-ancova-regex-escape

Conversation

@gwangjinkim

@gwangjinkim gwangjinkim commented Oct 2, 2026 •

Copy link
Copy Markdown

The reference arm level was pasted unescaped into a regular expression when extracting the treatment level from the emmeans contrast labels, so levels such as "Tirzepatide + Placebo" gave empty difference, CI and p-value cells. Escape it with a new internal escape_regex() helper.

Also match the extracted level with or without the parentheses emmeans adds, instead of stripping a trailing ")" unconditionally, which dropped the contrast for treatment levels such as "ARM B (x)" (snapshot updated).

Claude-Session: https://claude.ai/code/session_01VgDfDKtUjnHDRwMAo5HAdo

Pull Request

Fixes #1471

…ters (pharmaverse#1471)

The reference arm level was pasted unescaped into a regular expression when
extracting the treatment level from the emmeans contrast labels, so levels
such as "Tirzepatide + Placebo" gave empty difference, CI and p-value cells.
Escape it with a new internal escape_regex() helper.

Also match the extracted level with or without the parentheses emmeans adds,
instead of stripping a trailing ")" unconditionally, which dropped the
contrast for treatment levels such as "ARM B (x)" (snapshot updated).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VgDfDKtUjnHDRwMAo5HAdo

@Melkiades Melkiades left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm! Thanks @gwangjinkim for the addition ;)

This branch has not been deployed

No deployments
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.

[Bug]: summarize_ancova fails to return contrast rows when ref_group contains regex metacharacters such as +

3 participants