format_ae_listing(): AEDOSDUR parser errors on repeated Y/M/D designator and is not vectorized
I maintainer di solito rispondono entro 2 giorni
Una pull request collegata è già stata integrata.
- #162 di @yihui — integrata
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 65/100
Direzione di ricerca
The bug is in R/ae_listing.R lines 458-501. Start by reading the format_ae_listing() function and the loop that parses AEDOSDUR. Understand how gregexpr works and why a repeated designator causes an error. Look into vectorized regex solutions using sub or regmatches. Check related issues #138 and #148 for context. A fix should replace the loop with a vectorized parser and handle malformed input gracefully. Test with sample data containing repeated 'Y', 'M', or 'D' letters.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The Total_Dose_on_Day_of_AE_Onset derivation in format_ae_listing() parses the ISO-8601-like AEDOSDUR string one row at a time (R/ae_listing.R, around lines 458-501), branching on unlist(gregexpr("Y", ...)) > 0 etc.:
for (i in 1:length(res[["AEDOSDUR"]])) {
if (unlist(gregexpr("Y", res[["ymd"]][i])) > 0) { ... }
if (unlist(gregexpr("M", res[["ymd"]][i])) > 0) { ... }
if (unlist(gregexpr("D", res[["ymd"]][i])) > 0) { ... }
}
Bug. gregexpr() returns every match position. If a value contains a designator letter more than once, the result has length > 1, and if (... > 0) raises a hard error on R >= 4.2:
r <- unlist(gregexpr("Y", "1Y2Y3D")) # c(2, 4)
if (r > 0) "x"
#> Error: the condition has length > 1
Valid ISO 8601 durations use each designator once, so this is latent, but any malformed / dirty AEDOSDUR value triggers it. Also note gregexpr matches literally, so an unexpected letter elsewhere in the string could match.
Secondary (readability / performance). The loop calls gregexpr()/substring() roughly nine times per row for a task a single vectorized regex handles. A capture-group approach (e.g. sub("^(?:([0-9]+)Y)?(?:([0-9]+)M)?(?:([0-9]+)D)?$", ...) or regmatches) removes both the loop and the length>1 hazard, and pluralizes units cleanly.
Related cleanup: #138, #148.
- Lingua principale
- R
- Stelle
- 23
- Fork
- 6
- Merge medio
- 2g 16h
- PR unite (30g)
- 16
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Merck/forestly
-
Installed vignettes show blank tables/plots: self_contained: no drops lt assets on R CMD buildAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di Merck/forestly
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
HelenaLC/spatialdataR#284 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
mlr-org/mlr3cmprsk#42 ·
I maintainer di solito rispondono entro 1 giorno
-
Hackathon: Tier 1
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
pharmaverse/logrx#309 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100