if (requireNamespace("bbr", quietly = TRUE)) {
# Build a bbr-style model directory from the bundled pheno_saemimp example
src_dir <- system.file("pheno_saemimp", package = "xpose.xtras")
mod_dir <- tempfile("xp_from_bbr_ex")
dir.create(mod_dir)
file.copy(file.path(src_dir, "run18.mod"), file.path(mod_dir, "18.mod"))
out_dir <- file.path(mod_dir, "18")
dir.create(out_dir)
out_files <- setdiff(list.files(src_dir, pattern = "^run18\\."), "run18.mod")
for (f in out_files) {
file.copy(
file.path(src_dir, f),
file.path(out_dir, paste0("18.", sub("^run18\\.", "", f)))
)
}
# bbr considers a run finished once bbi has written this file
writeLines("{}", file.path(out_dir, "bbi_config.json"))
mod <- bbr::new_model(file.path(mod_dir, "18"), .description = "Phenobarbital SAEM model")
print(xp_from_bbr(mod))
unlink(mod_dir, recursive = TRUE)
}
Run the code above in your browser using DataLab