This function generates a PKNCA units table including the potential unit segregating columns among the dose and/or concentration groups.
Details
The function performs the following steps:
Ensures the unit columns (e.g.,
concu,timeu,doseu,amountu) exist in the inputs.Joins the concentration and dose data based on their grouping columns.
Generates a PKNCA units table for each group, including conversion factors and custom units.
Returns a unique table with relevant columns for PKNCA analysis.
Any NA units in groups already containing at least one valid value will be ignored from the creation of the units table.
Examples
# Assuming `o_conc` and `o_dose` are valid PKNCA objects:
# 1) Sharing group variables in their formulas
# 2) Time units are the same within dose groups
# 3) Units are the same for subjects within the same concentration group
d_conc <- data.frame(
subj = 1,
analyte = rep(c("A", "B"), each = 2),
concu = rep(c("ng/mL", "ug/mL"), each = 2),
conc = c(0, 2, 0, 5),
time = rep(0:1, 2),
timeu = "h"
)
d_dose <- data.frame(
subj = 1,
dose = 100,
doseu = "mg",
time = 0,
timeu = "h"
)
o_conc <- PKNCA::PKNCAconc(d_conc, conc ~ time | subj / analyte, concu = "concu")
o_dose <- PKNCA::PKNCAdose(d_dose, dose ~ time | subj, doseu = "doseu")
units_table <- PKNCA_build_units_table(o_conc, o_dose)