Skip to contents

Verify that the compartment exists in a model

Usage

assertCompartmentExists(ui, x)

testCompartmentExists(ui, x)

Arguments

ui

is the model to test

x

The value to test (can be a vector of strings)

Value

the value of the compartment that exists; if it is a vector returns the first item that matches

Functions

  • testCompartmentExists(): Test if compartment exists

Author

Matthew Fidler & Bill Denney

Examples

# \donttest{
mod <- function() {
  ini({
    tka <- log(1.1)
    tcl <- log(3)
    tv <- log(30)
  })
  model({
    ka <- exp(tka)
    cl <- exp(tcl)
    v <- exp(tv)
    d/dt(depot) <- -ka * depot
    d/dt(central) <- ka * depot - cl / v * central
  })
}
# returns the first compartment that exists
assertCompartmentExists(mod, c("gut", "depot"))
#>  
#>  
#> ℹ parameter labels from comments are typically ignored in non-interactive mode
#> ℹ Need to run with the source intact to parse comments
testCompartmentExists(mod, "gut")
#>  
#>  
#> ℹ parameter labels from comments are typically ignored in non-interactive mode
#> ℹ Need to run with the source intact to parse comments
#> [1] FALSE
# }