-
Notifications
You must be signed in to change notification settings - Fork 11
fix: resolve interval parameter show raw PPTESTCDs instead of labels in NCA results #1305 #1321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 7 commits
5b28c59
cdd2d5e
a4db6ac
955c231
ea53bcb
4fe1b66
465879e
e905182
d41e634
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -221,8 +221,23 @@ add_label_attribute <- function(df, myres) { | |
| !is.na(PPSTRESU) & PPSTRESU != "" ~ paste0(PPTESTCD, "[", PPSTRESU, "]"), | ||
| TRUE ~ PPTESTCD | ||
| ), | ||
| PPTESTCD_cdisc = translate_terms(PPTESTCD, mapping_col = "PPTESTCD", target_col = "PPTEST") | ||
| PPTESTCD_cdisc_raw = translate_terms( | ||
| PPTESTCD, mapping_col = "PPTESTCD", target_col = "PPTEST" | ||
| ), | ||
| PPTESTCD_cdisc = PPTESTCD_cdisc_raw | ||
| ) %>% | ||
| rowwise() %>% | ||
| mutate( | ||
| PPTESTCD_cdisc = if (type_interval == "manual") { | ||
| label <- PPTESTCD_cdisc_raw | ||
| label <- gsub("T1", as.character(start), label) | ||
| label <- gsub("T2", as.character(end), label) | ||
| label | ||
| } else { | ||
| PPTESTCD_cdisc | ||
| } | ||
| ) %>% | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue 1: Duplicated This function is now identical to the one in Proposed fix: Remove this copy entirely and call the exported version from # In pivot_wider_pknca_results.R, line 167 already does:
pivoted_res <- add_label_attribute(pivoted_res, myres)
# This will resolve to the exported version in R/label_operators.R
# once the local duplicate is removed.The local copy is marked |
||
| ungroup() %>% | ||
| select(PPTESTCD_cdisc, PPTESTCD_unit) %>% | ||
| distinct() %>% | ||
| pull(PPTESTCD_cdisc, PPTESTCD_unit) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue 2:
rowwise()is slow — use vectorizedifelse()+gsub()insteadrowwise()evaluates each row independently, which is slow on large data frames. This same pattern appears in 3 locations in this PR (R/label_operators.R,R/pivot_wider_pknca_results.R,inst/shiny/functions/selector_label.R).Since
gsub()is already vectorized andstart/endare column values, the wholerowwise() %>% mutate() %>% ungroup()block can be replaced with a single vectorizedmutate():Proposed fix (applies to all 3 locations):
No
rowwise()orungroup()needed. Same result, fewer lines, better performance.For
selector_label.R, the equivalent would be: