Description
When PPSTRESU is NA for all rows in a parameter group (e.g., partial AUC intervals like RCAMINT where no result was computed), multiple things break:
1. Descriptive statistics crash — calculate_summary_stats() crashes at line 67:
ModeUnit = names(sort(table(PPSTRESU), decreasing = TRUE, useNA = "ifany")[1])[1]
table() drops NAs by default, returning an empty table. names(sort(empty_table, ...)[1])[1] returns NULL, and dplyr::mutate cannot combine NULL with character results across groups:
Error in mutate:
! `ModeUnit` must return compatible vectors across groups.
✖ Can't combine NULL and non NULL results.
2. Column names get NA suffix — In pivot_wider_pknca_results.R and label_operators.R, the pattern ifelse(PPSTRESU != "", ...) returns NA when PPSTRESU is NA (since NA != "" evaluates to NA). This produces column names like RCAMINT_0-20NA instead of RCAMINT_0-20.
Both issues stem from export_cdisc.R line 394 setting PPSTRESU = ifelse(is.na(PPSTRES), NA_character_, PPSTRESU), which is correct CDISC behavior but wasn't handled downstream.
To reproduce
- Upload a dataset with both SERUM and URINE specimens.
- In NCA settings, add partial AUC intervals (e.g., AUCINT and RCAMINT).
- Run NCA computation.
- In NCA Results > Select Parameters, observe
RCAMINT_0-20NA instead of RCAMINT_0-20.
- Navigate to Descriptive Statistics — app crashes.
The issue is on main.
First reported in #1169 (review).
Expected behaviour
- Descriptive statistics should handle groups where all unit values are
NA without crashing.
- Manual interval parameters should appear as
RCAMINT_0-20 (without NA suffix) in NCA results.
Description
When
PPSTRESUisNAfor all rows in a parameter group (e.g., partial AUC intervals likeRCAMINTwhere no result was computed), multiple things break:1. Descriptive statistics crash —
calculate_summary_stats()crashes at line 67:table()drops NAs by default, returning an empty table.names(sort(empty_table, ...)[1])[1]returnsNULL, anddplyr::mutatecannot combineNULLwith character results across groups:2. Column names get
NAsuffix — Inpivot_wider_pknca_results.Randlabel_operators.R, the patternifelse(PPSTRESU != "", ...)returnsNAwhenPPSTRESUisNA(sinceNA != ""evaluates toNA). This produces column names likeRCAMINT_0-20NAinstead ofRCAMINT_0-20.Both issues stem from
export_cdisc.Rline 394 settingPPSTRESU = ifelse(is.na(PPSTRES), NA_character_, PPSTRESU), which is correct CDISC behavior but wasn't handled downstream.To reproduce
RCAMINT_0-20NAinstead ofRCAMINT_0-20.The issue is on
main.First reported in #1169 (review).
Expected behaviour
NAwithout crashing.RCAMINT_0-20(withoutNAsuffix) in NCA results.