Create new model by copying existing model. Useful for iterating during model
development. Also fills based_on field by default, for constructing model
ancestry. See "Using based_on field" vignette for details.
Usage
copy_model_from(
.parent_mod,
.new_model = NULL,
.description = NULL,
.based_on_additional = NULL,
.add_tags = NULL,
.star = NULL,
.inherit_tags = FALSE,
.update_model_file = TRUE,
.overwrite = FALSE
)
# S3 method for class 'bbi_nonmem_model'
copy_model_from(
.parent_mod,
.new_model = NULL,
.description = NULL,
.based_on_additional = NULL,
.add_tags = NULL,
.star = NULL,
.inherit_tags = FALSE,
.update_model_file = TRUE,
.overwrite = FALSE
)Arguments
- .parent_mod
Model to copy from
- .new_model
Path to the new model, either absolute or relative to the path to
.parent_mod. Represents an absolute model path, which is the path to the YAML file and model file, both without extension, and the output directory (once the model is run). Numeric values will be coerced to character. IfNULL, the default, will try to increment to the next integer in the destination directory. See examples for usage.- .description
Character scalar description of new model run. This will be stored in the yaml (and can be viewed later in
run_log()).- .based_on_additional
Character vector of path(s) to other models that this model was "based on." These are used to reconstuct model developement and ancestry. Paths must be relative to
.new_modelpath. Note that the.parent_modelwill automatically be added to thebased_onfield, so no need to include that here.Character vector with any new tags(s) to be added to
{.new_model}.yaml- .star
Boolean, marks model to indicate special interest level.
If
FALSE, the default, new model will only have any tags passed to.add_tagsargument. IfTRUEinherit any tags from.parent_mod, with any tags passed to.add_tagsappended.- .update_model_file
Only relevant to NONMEM models. If
TRUE, the default, update the newly created model file. IfFALSE, new model file will be an exact copy of its parent. For a NONMEM model, this currently means only the$PROBLEMline in the new control stream will be updated to readSee {.new_model}.yaml. Created by bbr..- .overwrite
If
FALSE, the default, function will error if a model file already exists at specified.new_modelpath. IfTRUEany existing file at.new_modelwill be overwritten silently.
Methods (by class)
copy_model_from(bbi_nonmem_model):.parent_modtakes abbi_nonmem_modelobject to use as a basis for the copy.
Examples
if (FALSE) { # \dontrun{
parent <- read_model("/foo/parent")
# create model file at /bar/child.ctl and YAML at /bar/child.yaml
copy_model_from(parent, "/bar/child", "child model with absolute path")
# create model file at /foo/child.ctl and YAML at /foo/child.yaml
copy_model_from(parent, "child", "relative to parent model path")
mod1 <- read_model("/path/to/1")
# create model file at /path/to/2.ctl and YAML at /path/to/2.yaml
copy_model_from(mod1, "increments to next integer by default")
# create model file at /path/to/3.ctl and YAML at /path/to/3.yaml
copy_model_from(mod1, 3, "numeric input works")
# create model file at /path/to/100.1.ctl and YAML at /path/to/100.1.yaml
copy_model_from(mod1, 100.1, "a period is okay")
} # }
