fix: handle all-NA PPSTRESU groups in descriptive statistics#1217
Open
fix: handle all-NA PPSTRESU groups in descriptive statistics#1217
Conversation
table() without useNA drops NA values, returning an empty table when all PPSTRESU values are NA. names(sort(empty_table, ...)[1])[1] then returns NULL, which dplyr::mutate cannot combine with character results from other groups. Extract .mode_unit() helper that returns NA_character_ for empty tables. Also guard the downstream PPTESTCD formatting against NA ModeUnit. Closes #1216 Co-authored-by: Ona <no-reply@ona.com>
- Test calculate_summary_stats with a mix of normal and all-NA unit groups (CMAX + RCAMINT scenario from the bug report) - Test .mode_unit edge cases: all-NA, empty vector, mixed NA/values Co-authored-by: Ona <no-reply@ona.com>
Co-authored-by: Ona <no-reply@ona.com>
The helper was inserted between the roxygen docs and the function definition, which would cause devtools::document() to detach the docs from calculate_summary_stats. Moving .mode_unit (with @nord) to the top of the file keeps both roxygen blocks correctly associated. Co-authored-by: Ona <no-reply@ona.com>
…rmaverse/aNCA into 1216-bug/modeunit-null-crash
…rmaverse/aNCA into 1216-bug/modeunit-null-crash
Collaborator
Collaborator
Author
|
@Shaakon35 did you include |
Collaborator
When PPSTRESU is NA (e.g., RCAMINT with no computed result), ifelse(PPSTRESU != "", ...) returns NA, producing column names like RCAMINT_0-20NA. Add !is.na(PPSTRESU) guard in all 4 locations: main interval PPTESTCD, manual interval_name (vals + exclude), and add_label_attribute. Co-authored-by: Ona <no-reply@ona.com>
Same NA PPSTRESU fix as pivot_wider_pknca_results — the exported add_label_attribute has the identical case_when pattern. Co-authored-by: Ona <no-reply@ona.com>
Verify that pivot_wider_pknca_results and add_label_attribute produce clean column names (e.g., RCAMINT_0-20) instead of NA-suffixed ones (RCAMINT_0-20NA) when PPSTRESU is NA. Co-authored-by: Ona <no-reply@ona.com>
Co-authored-by: Ona <no-reply@ona.com>
The test was injecting rows with mismatched start/end vs start_dose/ end_dose, causing add_label_attribute to produce a different number of mapped columns than the pivot. Use a template row and compute consistent absolute times from dose_time. Co-authored-by: Ona <no-reply@ona.com>
Collaborator
Author
|
hey @Shaakon35, it is "correct". The problem is that right now when you request an interval parameter you do it for all I changed it so now the NA units show in a clean way:
However, notice that this is merely aesthetic. Let me know if you think something else should be done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Issue
Closes #1216
Description
When
PPSTRESUisNAfor all rows in a parameter group (common with partial AUC intervals like RCAMINT where no result was computed), two things break:Descriptive statistics crash —
table(PPSTRESU)drops NAs, returning an empty table.names(sort(empty_table, ...)[1])[1]returnsNULL, whichdplyr::mutatecan't combine with character results from other groups.Column names get
NAsuffix —ifelse(PPSTRESU != "", ...)returnsNAwhenPPSTRESUisNA, producing names likeRCAMINT_0-20NA.Fixes:
.mode_unit()helper incalculate_summary_stats.Rthat returnsNA_character_for empty/all-NA inputPPTESTCDformatting againstNAModeUnit!is.na(PPSTRESU)guard to allifelse(PPSTRESU != "", ...)patterns inpivot_wider_pknca_results.R(4 locations) andlabel_operators.R(2 locations)Definition of Done
calculate_summary_stats()no longer crashes with all-NA unit groupsRCAMINT_0-20(notRCAMINT_0-20NA)How to test
RCAMINT_0-20(noNAsuffix)Contributor checklist
.scsschange was done, rundata-raw/compile_css.RNotes to reviewer
First reported in #1169 (review). The root cause is that
export_cdisc.Rcorrectly setsPPSTRESU = NAwhenPPSTRESisNA(CDISC SD0027), but downstream code assumedPPSTRESUis always a non-NA string. The fix adds NA guards at all 7 affected locations across 3 files."