Skip to contents

PKPDsim allows you to export your ODE model to a precompiled R package. The benefit of doing so is that compilation (which usually takes ~5 seconds) has to be done only when the package is installed, and not when it is reloaded into R. This is useful for example when you want to create a Shiny app using a PKPDsim model, as it will remove the delay due to the compilation when starting the Shiny app. You can export to a package using the package argument to new_ode_model. With the install option you can control whether the package should be installed into R (default), or exported to a zip-file (install = FALSE). Example:

p <- list(CL = 5, V = 50)
reg <- new_regimen(amt = 100, n = 4, interval = 12, type = "bolus",  cmt = 1)

new_ode_model(
  code = "
    dAdt[1] = -(CL/V) * A[1]
  ",
  dose = list(cmt = 1, bioav = 1),
  obs = list(cmt = 1, scale = "V"),
  parameters = p,
  package = "pktest",
  install = TRUE
)

To load the library and model:

library(pktest)
mod <- pktest::model()

To simulate from the model:

sim(
  ode = mod, 
  parameters = p, 
  regimen = reg
)