Skip to content

Bug: Descriptive statistics crash when PPSTRESU is all NA for a parameter group #1216

@Gero1999

Description

@Gero1999

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 crashcalculate_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

  1. Upload a dataset with both SERUM and URINE specimens.
  2. In NCA settings, add partial AUC intervals (e.g., AUCINT and RCAMINT).
  3. Run NCA computation.
  4. In NCA Results > Select Parameters, observe RCAMINT_0-20NA instead of RCAMINT_0-20.
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions