Build a NONMEM-format dataset from cleaned DM/EX/PC tables.
Time-varying covariates (VS, LB, ...) are NOT merged here. Use
merge_cov_locf afterwards to add them. CRCL is added
separately via add_crcl_cg. Molar conversion is done with
nm_to_molar.
build_nm_dataset(
DM,
EX,
PC,
IDs = NULL,
id_prefix = "",
id_func = NULL,
dose_cmt = 1L,
verbose = FALSE
)data.frame with columns ID, SUBJID, DAT2, TIME, AMT, RATE, CMT, DV, MDV, <DM-columns ...>.
data.frame with one row per subject. Must contain SUBJID; any other columns are merged in as subject-level constants.
dose records (see build_dose_records).
observation records (see build_obs_records).
character vector of SUBJIDs to keep. NULL (default) is the intersect of EX and PC where DV > 0.
character. When id_func is NULL,
ID = paste0(id_prefix, SUBJID).
function(SUBJID) -> character ID. Overrides id_prefix.
default compartment for dose records lacking a CMT column.
print progress. Default FALSE.
Records are sorted by SUBJID, DAT2, TIME, CMT, MDV, AMT. At tied (SUBJID, DAT2, TIME, CMT, MDV), AMT = 0 (observation) sorts before AMT > 0 (dose) so a pre-dose observation precedes the dose given at the same minute.