-
Notifications
You must be signed in to change notification settings - Fork 7
Bug: PKNCA_update_data_object custom_units_table join ignores group columns (PARAM, PCSPEC) #1159
Description
Description
PKNCA_update_data_object applies custom_units_table via dplyr::rows_update() with a hardcoded join key by = c("PPTESTCD", "PPORRESU") (line 377 of R/PKNCA.R).
However, PKNCA_build_units_table can produce a units table that includes additional group columns like PARAM or PCSPEC when different analytes or matrices have different concentration units. In that case, PPTESTCD + PPORRESU no longer uniquely identifies rows — the same parameter (e.g. cmax) with the same original unit (e.g. ng/mL) can appear once per PARAM.
When custom_units_table also contains these group columns, rows_update will error because the by key matches multiple rows. If the custom table does not contain the group columns, the update is applied ambiguously.
The Shiny app itself is not affected because it never passes custom_units_table to this function — it applies custom units separately in tab_nca.R using dynamic by_cols. But the exported R script (script_template.R) calls PKNCA_update_data_object(..., custom_units_table = units_table) directly, so the bug manifests there.
To reproduce
- Load a dataset with two analytes that have different concentration units (e.g. Analyte A in
ng/mL, Analyte B inug/mL). - Modify a unit in the units table (e.g. change
cmaxPPSTRESU for Analyte A). - Export the R script and run it —
PKNCA_update_data_objectwill fail or apply the wrong conversion.
Expected behaviour
PKNCA_update_data_object should use dynamic join keys (matching the pattern in tab_nca.R and units_table.R) so that group columns like PARAM and PCSPEC are included in the rows_update key when present.</n"
Metadata
Metadata
Assignees
Labels
Type
Projects
Status