Create a new observer
create_observer.RdCreate a single Observer from named arguments. This is a thin factory
around Observer$new() that builds the raw list shape for you and
composes with create_observer_set() via
create_observer_set(observers = list(...)).
An observer is a simulation-time formula that computes a derived quantity from the underlying model (for example an amount observer or a container observer). It is not itself a building block; it lives inside an ObserverSet.
Usage
create_observer(
name,
type,
dimension = NULL,
formula = NULL,
formula_references = NULL,
container_criteria = NULL,
molecule_list = NULL
)Arguments
- name
Character. Name of the observer (required).
- type
Character. The observer type, one of
"Amount"(anAmountObserverBuilder) or"Container"(aContainerObserverBuilder). Any other value aborts (required).- dimension
Character. The dimension of the observed quantity. Omitted when
NULL.- formula
The observer's formula. Either a bare expression string (which becomes the inner
Formula$Formula), or a fullExplicitFormularaw list used as the wholeFormula. Omitted whenNULL.- formula_references
List of formula references, each a
create_formula_reference()output or an equivalent raw{Alias, Path, Dimension}list. Written to the formula'sReferences; supplying these withoutformulayields aFormulacarrying onlyReferences. Whenformulais a fullExplicitFormulalist that already carries its ownReferences, this argument overrides them. Omitted whenNULL.- container_criteria
List of container criteria, each a
create_descriptor_condition()output or an equivalent raw{Tag, Type}list. Written toContainerCriteria. Omitted whenNULL.- molecule_list
A
create_molecule_list()output or an equivalent raw list. Written toMoleculeList. Omitted whenNULL.
Value
An Observer object.
Examples
# Minimal amount observer
create_observer(name = "drug_amount", type = "Amount")
#>
#> ── Observer: drug_amount
#> • Type: Amount
# Container observer with all sub-properties
obs <- create_observer(
name = "brain_plasma_conc",
type = "Container",
dimension = "Concentration (molar)",
formula = "Conc_Br",
formula_references = list(
create_formula_reference(
"Conc_Br",
"Organism|Brain|Plasma|Drug|Concentration"
)
),
container_criteria = list(
create_descriptor_condition("Brain", "InContainer")
),
molecule_list = create_molecule_list(for_all = FALSE, include = "Drug")
)
# Compose into an observer set
create_observer_set(name = "BrainPlasmaConcentration", observers = list(obs))
#>
#> ── ObserverSet: BrainPlasmaConcentration ───────────────────────────────────────
#> • 1 observer