hallowkm / RxODE

RxODE is an R package that facilitates easy simulations in R
20 stars 13 forks source link

model$dll$modVars is not initialised for new 'wd' #16

Closed coolbutuseless closed 5 years ago

coolbutuseless commented 7 years ago

Package Version 0.6.0

Issue: Sometimes the model will compile, but the 'dll' information will not be read into the 'model' variable. This then results in an error as model$dll$modelVars is NULL.

This seems to be related to whether or not the model 'wd' exists already or not.

This issue came to light as I'm trying to run RxODE within a package test suite (using testthat), and it will run fine standalone, but will fail when building the package with "R CMD check".

suppressPackageStartupMessages({
  library(RxODE)
})

model_text <- "
  C2 = centr/V2;
  C3 = peri/V3;
  d/dt(depot) =-KA*depot;
  d/dt(centr) = KA*depot - CL*C2 - Q*C2 + Q*C3;
  d/dt(peri)  =                    Q*C2 - Q*C3;
  d/dt(eff)  = Kin - Kout*(1-C2/(EC50+C2))*eff;
  "

params <- data.frame(
  KA=2.94E-01, CL=1.86E+01, V2=4.02E+01, # central
  Q=1.05E+01,  V3=2.97E+02,              # peripheral
  Kin=1, Kout=1, EC50=200                # effects
)

event_table <- RxODE::eventTable()
event_table$add.dosing(dose=10000, nbr.doses=10, dosing.interval=12)
event_table$add.sampling(0:240)

modName <- paste(sample(LETTERS, 5), collapse="")
model   <- RxODE::RxODE(model = model_text, modName=modName, wd='mytempdir')

res <- model$solve(params = params, events = event_table)
# >> Error in if (transit_abs) { : argument is of length zero

model$dll$modVars
# >> NULL

# But if it is now run a second time, with the directory already existing, 
# it works fine
model   <- RxODE::RxODE(model = model_text, modName=modName, wd='mytempdir')
mattfidler commented 7 years ago

Thanks for the bug report. I will look into it. Development has moved to

github.com/nlmixrdevelopment/RxODE

I have opened a bug there too.

https://github.com/nlmixrdevelopment/RxODE/issues/4

mattfidler commented 7 years ago

This is fixed in the development version of RxODE

You can install by:

devtools::install_github("nlmixrdevelopment/RxODE");