format_ae_listing(): AE duration set to NA (not "Unknown") for outcomes outside two hardcoded values
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
Research direction
The bug is in R/ae_listing.R around lines 394-402 in the format_ae_listing() function. First, read the function to understand how ADURN and AEOUT are used. Then, create a small test to reproduce the issue with the provided examples. The fix is to replace the charmatch() calls with an exact membership test using %in%. After making the change, run any existing tests for this function to ensure the fix works and doesn't break other behavior.
Written by the indexing model from the issue text.
Description
When ADURN is missing, format_ae_listing() derives the Duration value from AEOUT (R/ae_listing.R, around lines 394-402):
na_dur <- is.na(res[["ADURN"]])
if (any(na_dur)) {
aeout_na <- toupper(res[["AEOUT"]][na_dur])
res[["Duration"]][na_dur] <- ifelse(
charmatch(aeout_na, "RECOVERING/RESOLVING") > 0 |
charmatch(aeout_na, "NOT RECOVERED/NOT RESOLVED") > 0,
"Continuing", "Unknown"
)
}
Two problems with charmatch() here:
-
NAleaks into the result.charmatch(x, table)returnsNAwhenxmatches nothing intable. For any outcome that is neitherRECOVERING/RESOLVINGnorNOT RECOVERED/NOT RESOLVED(e.g.FATAL,RECOVERED/RESOLVED), bothcharmatch()calls returnNA, so theifelse()condition isNA | NA = NAandifelse(NA, ...)yieldsNA. The intended fallback"Unknown"is never reached for those rows. -
Silent prefix matching.
charmatch()does partial (prefix) matching, socharmatch("R", "RECOVERING/RESOLVING")returns1. An exact comparison was almost certainly intended.
Reproducer:
f <- function(aeout) ifelse(
charmatch(aeout, "RECOVERING/RESOLVING") > 0 |
charmatch(aeout, "NOT RECOVERED/NOT RESOLVED") > 0,
"Continuing", "Unknown")
f("FATAL") # NA (expected "Unknown")
f("RECOVERED/RESOLVED") # NA (expected "Unknown")
Suggested fix: use an exact set-membership test instead of charmatch():
res[["Duration"]][na_dur] <- ifelse(
aeout_na %in% c("RECOVERING/RESOLVING", "NOT RECOVERED/NOT RESOLVED"),
"Continuing", "Unknown"
)
This affects normal, valid data whenever a subject has a missing AE duration and an outcome outside the two listed categories.
- Dominant language
- R
- Stars
- 22
- Forks
- 6
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 10
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.
More from Merck/forestly
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 65/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Similar issues
-
Affects Web App documentation PRIORITY LOW
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 1/5 Under an hour Newbie friendliness 80/100
hubverse-org/hubCI#36 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Release 1.4.0 Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
pharmaverse/pharmaverseadam#170 ·