Skip to contents

Verify that a value is a valid nlmixr2 compartment name

Usage

assertCompartmentName(x)

assertVariableName(x)

assertParameterValue(x)

assertExists(ui, x)

testExists(ui, x)

Arguments

x

The value to test

ui

when needed, this is the rxode2/nlmixr2 model

Value

The value or an error

Functions

  • assertVariableName(): Verify that a value is a valid nlmixr2 variable name

  • assertParameterValue(): Verify that a value is a valid nlmixr2 parameter value

  • assertExists(): Assert compartment/variable exists

  • testExists(): Test compartment/variable exists

Author

Bill Denney

Examples

assertCompartmentName("central")
assertVariableName("cl")
assertParameterValue(0.5)
try(assertCompartmentName("1central")) # invalid name
#> Error in assertCompartmentName("1central") : 
#>   Assertion on '"1central"' failed: Must comply to pattern '^[.]*[a-zA-Z]+[a-zA-Z0-9._]*$'.
# \donttest{
mod <- function() {
  ini({
    tcl <- log(3)
    tv <- log(30)
  })
  model({
    cl <- exp(tcl)
    v <- exp(tv)
    d/dt(central) <- -cl / v * central
  })
}
assertExists(mod, "central")
#>  
#>  
#> ℹ parameter labels from comments are typically ignored in non-interactive mode
#> ℹ Need to run with the source intact to parse comments
testExists(mod, "ka")
#>  
#>  
#> ℹ parameter labels from comments are typically ignored in non-interactive mode
#> ℹ Need to run with the source intact to parse comments
#> [1] FALSE
# }