Learn R Programming

Certara.RDarwin (version 1.2.0)

add_Spaces: Add Multiple Model Spaces to a PMLModels Object

Description

Merges a list of new model spaces into an existing PMLModels object.

Usage

add_Spaces(Spaces, NewSpaces, NewSpacesNames = character())

Value

An updated PMLModels object (a named list) containing all the original spaces plus all spaces from NewSpaces. The class "PMLModels" is preserved.

Arguments

Spaces

A PMLModels object (a named list) representing the existing collection of model spaces. Can be an empty list or a previously created PMLModels object.

NewSpaces

A list where each element is an internal representation of a single model space (e.g., the list structure produced by create_ModelPK or create_CustomSpace). If this list is named, these names will be used unless overridden by NewSpacesNames.

NewSpacesNames

An optional character vector providing explicit names for the spaces listed in NewSpaces. If provided: If omitted, the names attached to the NewSpaces list itself will be used.

Details

This function provides a general mechanism for combining collections of model spaces.

Naming and Collision Handling: This behavior differs from add_CustomSpace(), which automatically renames on collision. add_Spaces requires unique, non-colliding names for the merge.

See Also

add_CustomSpace() for adding a single custom space with automatic renaming.

Examples

Run this code
pk_model1 <-
  create_ModelPK(CompartmentsNumber = 1,
                 Absorption = "Intravenous")
pk_models2 <- create_ModelPK(CompartmentsNumber = c(2, 3),
                             Absorption = "First-Order")

# Combine two PMLModels objects (using names from pk_models2)
combined1 <- add_Spaces(pk_model1, pk_models2)
names(combined1)

# Combine using explicit new names
combined2 <-
  add_Spaces(pk_model1,
             pk_models2,
             NewSpacesNames = c("Model_A", "Model_B"))
names(combined2)

# Add a list containing a single custom space
custom_pml <- "test(){ fixef(p=1) }"
custom_space_list <-
  create_CustomSpace(custom_pml, "MyCustom")
combined3 <-
  add_Spaces(pk_model1, custom_space_list)
names(combined3)

Run the code above in your browser using DataLab