Skip to contents

Assert a variable exists in the model

Usage

assertVariableExists(ui, x)

testVariableExists(ui, x)

Arguments

ui

rxode2 ui model

x

does the x variable exist in the model. If it is a vector of variable check to see if any exists, but all must be valid nlmixr2 variable names

Value

variable that matches, in the case of multiple variables, the first that matches. If nothing matches return error

Functions

  • testVariableExists(): Test if variable exists

Author

Matthew L. Fidler

Examples

# \donttest{
mod <- function() {
  ini({
    tcl <- log(3)
    tv <- log(30)
    add.sd <- 0.7
  })
  model({
    cl <- exp(tcl)
    v <- exp(tv)
    d/dt(central) <- -cl / v * central
    cp <- central / v
    cp ~ add(add.sd)
  })
}
assertVariableExists(mod, "cp")
#>  
#>  
#> ℹ parameter labels from comments are typically ignored in non-interactive mode
#> ℹ Need to run with the source intact to parse comments
testVariableExists(mod, "kel")
#>  
#>  
#> ℹ parameter labels from comments are typically ignored in non-interactive mode
#> ℹ Need to run with the source intact to parse comments
#> [1] FALSE
# }