GithubHelp home page GithubHelp logo

nlmixr2 / rxode2 Goto Github PK

View Code? Open in Web Editor NEW
24.0 24.0 6.0 450.97 MB

rxode2

Home Page: https://nlmixr2.github.io/rxode2/

License: GNU General Public License v3.0

R 60.46% Shell 0.01% C 16.59% C++ 17.24% GAP 0.16% Fortran 5.54%

rxode2's Introduction

nlmixr2

Cran updating status R-CMD-check Codecov test coverage CodeFactor CRAN version CRAN total downloads CRAN total downloads

The vision of nlmixr2 is to develop a R-based open-source nonlinear mixed-effects modeling software package that can compete with commercial pharmacometric tools and is suitable for regulatory submissions.

In short, the goal of nlmixr2 is to support easy and robust nonlinear mixed effects models in R. This is supported by our team and advisory committee

Blog for more information

For more information about ongoing development, best practices, and news about nlmixr2, please see the nlmixr2 blog.

Installation

For all versions of R, we need to have a compiler setup to run nlmixr2 and rxode2

Windows compilation tools setup

For Windows the compilers come from RTools. Download and the install the version of RTools for your version of R from https://cran.r-project.org/bin/windows/Rtools/

Mac compilation tools setup

To setup the mac compilers, simply

  1. Install Xcode from app store

  2. Install gfortran:

    1. Download and install from https://mac.r-project.org/tools/

    2. Add gfortran directory to the path with: export PATH=$PATH:/usr/local/gfortran/bin

R package installation

Installation nlmixr2 itself is easiest the latest version of R because no further compilation is required and all supporting packages are available. From R, run:

install.packages("nlmixr2",dependencies = TRUE)

For R-4.0.x and R-4.1.x, the symengine package will need to be downgraded to run in those earlier R versions. This can be done by:

# install.packages("remotes")
remotes::install_version("symengine", version = "0.1.6")

followed by:

install.packages("nlmixr2",dependencies = TRUE)

Checking installation

You can check that your installation is likely setup correctly with the following command after installing the nlmixr2 package:

nlmixr2::nlmixr2CheckInstall()

Development version installation

Once the compilers are setup and a compatible version of symengine is installed, you can install the development version of nlmixr2 and its nlmixr2-family dependencies either by using the r-universe or by installing manually.

Install using the R universe

For many people this is the fastest way to install the development version of nlmixr2 since it provides binaries for mac, windows for the latest and last version of R (no need to wait for a compile).

install.packages(c("dparser", "nlmixr2data", "lotri", "rxode2ll",
                   "rxode2parse", "rxode2random", "rxode2et",
                   "rxode2", "nlmixr2est", "nlmixr2extra", "nlmixr2plot",
                   "nlmixr2"),
                 repos = c('https://nlmixr2.r-universe.dev',
                           'https://cloud.r-project.org'))

If you are using a Ubuntu latest flavor (at the time of this writing jammy) you can also use the binaries (though if you use bspm you should install any dependencies first to reduce your computation time)

# bspm::disable() # if you are using r2u or other ubuntu binary for CRAN
oldOptions <- options()

options(repos=c(
  linux = 'https://nlmixr2.r-universe.dev/bin/linux/jammy/4.2/',
  sources = 'https://nlmixr2.r-universe.dev',
  cran = 'https://cloud.r-project.org'
))
install.packages(c("dparser", "nlmixr2data", "lotri", "rxode2ll",
                   "rxode2parse", "rxode2random", "rxode2et",
                   "rxode2", "nlmixr2est", "nlmixr2extra", "nlmixr2plot",
                   "nlmixr2"))

options(oldOptions)
#bspm::enable()

Support packages from the R universe can also be installed for the packages in the nlmixr2 domain:

install.packages(c("xpose.nlmixr2", # Additional goodness of fit plots
                                    # baesd on xpose
                   "nlmixr2targets", # Simplify work with the
                                     # `targets` package
                   "babelmixr2", # Convert/run from nlmixr2-based
                                 # models to NONMEM, Monolix, and
                                 # initialize models with PKNCA
                   "nonmem2rx", # Convert from NONMEM to
                                # rxode2/nlmixr2-based models
                   "nlmixr2lib", # a model library and model
                                 # modification functions that
                                 # complement model piping
                   "nlmixr2rpt" # Automated Microsoft Word and
                                # PowerPoint reporting for nlmixr2
                   ),
                 repos = c('https://nlmixr2.r-universe.dev',
                           'https://cloud.r-project.org'))

# Some additional packages outside of the `nlmixr2.r-univers.dev`
# install.packages("remotes")
remotes::install_github("ggPMXdevelopment/ggPMX") # Goodness of fit plots
remotes::install_github("RichardHooijmaijers/shinyMixR") # Shiny run manager (like Piranha)

For Ubuntu latest it is similar

# bspm::disable() # if you are using r2u or other ubuntu binary for CRAN
oldOptions <- options()

options(repos=c(
  linux = 'https://nlmixr2.r-universe.dev/bin/linux/jammy/4.2/',
  sources = 'https://nlmixr2.r-universe.dev',
  cran = 'https://cloud.r-project.org'
))
install.packages(c("xpose.nlmixr2", "nlmixr2targets", "babelmixr2", "nonmem2rx", "nlmixr2lib", "nlmixr2rpt"))

options(oldOptions)
#bspm::enable()
# install.packages("remotes")
remotes::install_github("ggPMXdevelopment/ggPMX") # Goodness of fit plots
remotes::install_github("RichardHooijmaijers/shinyMixR") # Shiny run manager (like Piranha)

Install using remotes

This is sure to give the latest development version

# install.packages("remotes")
remotes::install_github("nlmixr2/dparser-R")
remotes::install_github("nlmixr2/nlmixr2data")
remotes::install_github("nlmixr2/lotri")
remotes::install_github("nlmixr2/rxode2ll")
remotes::install_github("nlmixr2/rxode2parse")
remotes::install_github("nlmixr2/rxode2random")
remotes::install_github("nlmixr2/rxode2et")
remotes::install_github("nlmixr2/rxode2")
remotes::install_github("nlmixr2/nlmixr2est")
remotes::install_github("nlmixr2/nlmixr2extra")
remotes::install_github("nlmixr2/nlmixr2plot")
remotes::install_github("nlmixr2/nlmixr2")

Optional supporting packages can be installed like so:

# install.packages("remotes")
# Goodness of fit plots
remotes::install_github("ggPMXdevelopment/ggPMX")
# Additional goodness of fit plots
remotes::install_github("nlmixr2/xpose.nlmixr2")
# Shiny run manager (like Piranha)
remotes::install_github("RichardHooijmaijers/shinyMixR")
# Simplify work with the `targets` package
remotes::install_github("nlmixr2/nlmixr2targets")
# Convert/run from nlmixr2-based models to NONMEM, Monolix, and initialize
# models with PKNCA
remotes::install_github("nlmixr2/babelmixr2")
# Convert from NONMEM to rxode2/nlmixr2-based models
remotes::install_github("nlmixr2/nonmem2rx")
# A library of models and model modification functions
remotes::install_github("nlmixr2/nlmixr2lib")
# Automated Microsoft Word and PowerPoint reporting for nlmixr2
remotes::install_github("nlmixr2/nlmixr2rpt")

Refreshing the installation with the latest CRAN version

If you have difficulties due to errors while compiling models, it may be useful to re-install all of nlmixr2 and its dependencies. For development versions, please use the remotes::install_github() or the install.package() with the r-universe above. For the stable version, please use the following command:

install.packages(c("dparser", "lotri", "rxode2ll", "rxode2parse",
                   "rxode2random", "rxode2et", "rxode2",
                   "nlmixr2data", "nlmixr2est", "nlmixr2extra",
                   "nlmixr2plot", "nlmixr2"))

Example

This is a basic example which shows you how to solve a common problem:

library(nlmixr2)

## The basic model consists of an ini block that has initial estimates
one.compartment <- function() {
  ini({
    tka <- log(1.57); label("Ka")
    tcl <- log(2.72); label("Cl")
    tv <- log(31.5); label("V")
    eta.ka ~ 0.6
    eta.cl ~ 0.3
    eta.v ~ 0.1
    add.sd <- 0.7
  })
  # and a model block with the error specification and model specification
  model({
    ka <- exp(tka + eta.ka)
    cl <- exp(tcl + eta.cl)
    v <- exp(tv + eta.v)
    d/dt(depot) <- -ka * depot
    d/dt(center) <- ka * depot - cl / v * center
    cp <- center / v
    cp ~ add(add.sd)
  })
}

## The fit is performed by the function nlmixr/nlmixr2 specifying the model, data and estimate
fit <- nlmixr2(one.compartment, theo_sd,  est="saem", saemControl(print=0))
#> [====|====|====|====|====|====|====|====|====|====] 0:00:00 
#> 
#> [====|====|====|====|====|====|====|====|====|====] 0:00:00 
#> 
#> [====|====|====|====|====|====|====|====|====|====] 0:00:00 
#> 
#> [====|====|====|====|====|====|====|====|====|====] 0:00:00 
#> 
#> [====|====|====|====|====|====|====|====|====|====] 0:00:00 
#> 
#> [====|====|====|====|====|====|====|====|====|====] 0:00:00 
#> 
#> [====|====|====|====|====|====|====|====|====|====] 0:00:00
print(fit)
#> ── nlmixr² SAEM OBJF by FOCEi approximation ──
#> 
#>  Gaussian/Laplacian Likelihoods: AIC() or $objf etc. 
#>  FOCEi CWRES & Likelihoods: addCwres() 
#> 
#> ── Time (sec $time): ──
#> 
#>            setup covariance  saem table compress    other
#> elapsed 0.000891   0.020004 2.792 0.043    0.017 2.397105
#> 
#> ── Population Parameters ($parFixed or $parFixedDf): ──
#> 
#>        Parameter  Est.     SE %RSE Back-transformed(95%CI) BSV(CV%) Shrink(SD)%
#> tka           Ka  0.46  0.196 42.7       1.58 (1.08, 2.33)     71.9    -0.291% 
#> tcl           Cl  1.01 0.0839 8.29       2.75 (2.34, 3.25)     27.0      3.42% 
#> tv             V  3.45 0.0469 1.36       31.6 (28.8, 34.7)     14.0      10.7% 
#> add.sd           0.694                               0.694                     
#>  
#>   Covariance Type ($covMethod): linFim
#>   No correlations in between subject variability (BSV) matrix
#>   Full BSV covariance ($omega) or correlation ($omegaR; diagonals=SDs) 
#>   Distribution stats (mean/skewness/kurtosis/p-value) available in $shrink 
#>   Censoring ($censInformation): No censoring
#> 
#> ── Fit Data (object is a modified tibble): ──
#> # A tibble: 132 × 19
#>   ID     TIME    DV  PRED    RES IPRED   IRES  IWRES eta.ka eta.cl   eta.v    cp
#>   <fct> <dbl> <dbl> <dbl>  <dbl> <dbl>  <dbl>  <dbl>  <dbl>  <dbl>   <dbl> <dbl>
#> 1 1      0     0.74  0     0.74   0     0.74   1.07  0.0988 -0.484 -0.0843  0   
#> 2 1      0.25  2.84  3.27 -0.433  3.87 -1.03  -1.49  0.0988 -0.484 -0.0843  3.87
#> 3 1      0.57  6.57  5.85  0.718  6.82 -0.247 -0.356 0.0988 -0.484 -0.0843  6.82
#> # ℹ 129 more rows
#> # ℹ 7 more variables: depot <dbl>, center <dbl>, ka <dbl>, cl <dbl>, v <dbl>,
#> #   tad <dbl>, dosenum <dbl>

Plotting outputs

Base R Graphics

You can use the built-in plot with the fit and it will produce a standard set of goodness of fit plots:

pdf(file="myplots.pdf")
plot(fit)
dev.off()

xpose.nlmixr2

The {xpose.nlmixr2} package extends xpose support for nlmixr2. You simply need to convert the fit results into an xpose database:

library(xpose.nlmixr2)
xpdb = xpose_data_nlmixr(fit)

Then you can use any of the xpose functions for generating goodness of fit plots:

library(xpose)
plt <- dv_vs_ipred(xpdb)

ggPMX

Another option is to use the ggPMX package. You first create a ggPMX controller object from the nlmixr fit object. Then that controller object can be used to generate figures:

library(ggPMX)
ctr = pmx_nlmixr(fit)
pmx_plot_dv_ipred(ctr)

rxode2's People

Contributors

billdenney avatar daj025 avatar eddelbuettel avatar hallowkm avatar kestrel99 avatar krlmlr avatar mattfidler avatar s0521 avatar timwaterhouse avatar wwang-at-github avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

rxode2's Issues

UI bug; used to work in old nlmixr ui

library(rxode2)
#> detected new version of rxode2, cleaning cache
#> rxode2 1.0.0 using 4 threads (see ?getRxThreads)
one.compartment <- function() {
  ini({
    tka <- 0.45 # Log Ka
    tcl <- 1 # Log Cl
    tv <- 3.45    # Log V
    eta.ka ~ 0.6
    eta.cl ~ 0.3
    eta.v ~ 0.1
    add.sd <- 0.7
  })
  model({
    ka <- exp(tka + eta.ka)
    cl <- exp(tcl + eta.cl)
    v <- exp(tv + eta.v)
    d/dt(depot) = -ka * depot
    d/dt(center) = ka * depot - cl / v * center
    cp = center / v
    cp ~ add(add.sd)
  })
  keep = c("WT")
  drop = c("depot")
}

rxode2(one.compartment)
#> ℹ parameter labels from comments will be replaced by 'label()'
#> Error in assign("model", fun, envir = .ret): invalid 'envir' argument

Created on 2022-02-02 by the reprex package (v2.0.0)

`logitNorm` doesn't work with focei currently

library(nlmixr2)

f <- function() {
  ini({
    tke <- 0.5
    eta.ke ~ 0.04
    prop.sd <- sqrt(0.1)
  })
  model({
    ke <- tke * exp(eta.ke)
    ipre <- 10 * exp(-ke * t)
    f2 <- ipre / (ipre + 5)
    f3 <- f2 * 3
    lipre <- log(ipre)
    ipre ~ prop(prop.sd)
  })
}

f %>% model(ipre ~ logitNorm(logit.sd, 0, 12)) %>%
  ini(logit.sd=sqrt(0.1)) -> tmp

tmp$foceiModel0
#> Error: cannot find additive standard deviation for 'ipre'; this parameter could be estimated by another endpoint, to fix move outside of error expression.

Created on 2022-01-26 by the reprex package (v2.0.0)

Should error on invalid error pipes

library(rxode2)
#> detected new version of rxode2, cleaning cache
#> rxode2 1.0.0 using 4 threads (see ?getRxThreads)

f <- function() {
  ini({
    tke <- 0.5
    eta.ke ~ 0.04
    prop.sd <- sqrt(0.1)
  })
  model({
    ke <- tke * exp(eta.ke)
    ipre <- 10 * exp(-ke * t)
    f2 <- ipre / (ipre + 5)
    f3 <- f2 * 3
    lipre <- log(ipre)
    ipre ~ prop(prop.sd)
  })
}

f %>% model(ipre~prop(f2,f3,c))
#>  ── rxode2-based Pred model ───────────────────────────────────────────────────── 
#>  ── Initalization: ──  
#> Fixed Effects ($theta): 
#> tke   c 
#> 0.5 1.0 
#> 
#> Omega ($omega): 
#>        eta.ke
#> eta.ke   0.04
#>  ── Model (Normalized Syntax): ── 
#> function() {
#>     ini({
#>         tke <- 0.5
#>         c <- 1
#>         eta.ke ~ 0.04
#>     })
#>     model({
#>         ke <- tke * exp(eta.ke)
#>         ipre <- 10 * exp(-ke * t)
#>         f2 <- ipre/(ipre + 5)
#>         f3 <- f2 * 3
#>         lipre <- log(ipre)
#>         ipre ~ prop(f2, f3, c)
#>     })
#> }

Created on 2022-01-21 by the reprex package (v2.0.0)

test-lincmt-solve.R crashes in Windows after test 252

Running test-lincmt-solve.R on Windows (but not on Linux) crashes after test 252. I cannot isolate the issue.

When I run the test manually, I sometimes get a crash after this line (below), but other times, there is no crash.

s1 <- rxSolve(sol.1c, params = c(V = 20, CL = 25), events = etSsB, sensType = sensType)

Running the tests automatically (devtools::test()) reliably crashes after test 252 in test-lincmt-solve.R.

Given some of your previous statements, my guess is that there is some form of race on dll creation/deletion.

Low Priority Feature Request: Push all output into messages with normal model compilation

I'm currently trying to make successful testing closer to silent (PR coming). With that, I found that suppressMessages() does captures everything but a few line feeds, and I don't see how to suppress those line feeds in a simple way. I think that this could be Windows- or Rstudio-specific.

A specific example where this occurs would be:

norm <- rxode2("
d/dt(y)  = dy
d/dt(dy) = mu*(1-y^2)*dy - y
## Initial conditions
y(0) = 2
dy(0) = 0
## mu
mu = 1 ## nonstiff; 10 moderately stiff; 1000 stiff
")
  jac <- norm
  jac <- suppressMessages(rxode2(jac, calcJac = TRUE))

I expected the final line to have no output, but there is an empty line generated.

I think that this may be related to progress bars and possibly this line:

Rprintf("\n");

Low Priority Feature request: See if et() can be sped up

When running the random number testing, this line takes longer than it seems like would be required. So, I think it would be good to see if it could be sped up (without making code unreadable).

I'll take this on at some point.

library(rxode2)
ev <- et(1, id = 1:70000)

Windows error with test-npde-mac.R

I get the following error when I run test-npde-mac.R on Windows 10.

== Testing test-npde-mac.R =====================================================
[ FAIL 0 | WARN 0 | SKIP 0 | PASS 0 ]Assertion failed!

Program: C:\PROGRA~1\R\R-41~1.2\bin\x64\Rterm.exe
File: C:/Users/Bill Denney/Documents/R/win-library/4.1/RcppEigen/include/Eigen/src/Core/PlainObjectBase.h, Line 285

Expression: (!(RowsAtCompileTime!=Dynamic) || (rows==RowsAtCompileTime)) && (!(ColsAtCompileTime!=Dynamic) || (cols==ColsAtCompileTime)) && (!(RowsAtCompileTime==Dynamic && MaxRowsAtCompileTime!=Dynamic) || (rows<=MaxRowsAtCompileTime)) && (!(ColsAtCompileTime==Dynamic && MaxColsAtCompileTime!=Dynamic) || (cols<=MaxColsAtCompileTime)) && rows>=0 && cols>=0 && "Invalid sizes when resizing a matrix or array."

Exited with status 3.

Simplify dataset and event documentation

Remove rxode2Test()

As discussed in #17, we plan to remove rxode2Test(). The test argument to rxode2Test() has the following values where the only values suggested in the documentation are "CRAN and not cran".

The rxode2Test() code suggest that it:

  • runs all tests if test="cran"
  • Runs other tests, only if Sys.getenv("NOT_CRAN") == "true" (I think that is set by testthat)
  • And otherwise skips the tests

I think that the underlying goal is to run all tests where test="cran" and skip tests that aren't labeled test="cran" on CRAN (but run them locally and on CI). Is that correct?

Second to that, there are several values other than "cran" for test. Do they need to be preserved? The other values used are:

  • demo
  • focei
  • indLin
  • lincmt
  • lvl2
  • norm
  • parseLincmt
  • parsing
  • plot
  • print
  • rxuse

Piping doens't work correctly in some situations

library(rxode2)
#> detected new version of rxode2, cleaning cache
#> rxode2 1.0.0 using 4 threads (see ?getRxThreads)
f <- function() {
  ini({
    tke <- 0.5
    eta.ke ~ 0.04
    prop.sd <- sqrt(0.1)
  })
  model({
    ke <- tke * exp(eta.ke)
    ipre <- 10 * exp(-ke * t)
    f2 <- ipre / (ipre + 5)
    ipre ~ prop(prop.sd)
  })
}


f <- rxode2(f)

trans <- function(f) {
  f %>% model(ipre ~ propF(prop.sd, f2)) %>% ini(prop.sd=sqrt(0.1))
}

trans(f)
#>  ── rxode2-based Pred model ───────────────────────────────────────────────────── 
#>  ── Initalization: ──  
#> Fixed Effects ($theta): 
#>       tke   prop.sd        f2 
#> 0.5000000 0.3162278 1.0000000 
#> 
#> Omega ($omega): 
#>        eta.ke
#> eta.ke   0.04
#>  ── Model (Normalized Syntax): ── 
#> function() {
#>     ini({
#>         tke <- 0.5
#>         prop.sd <- 0.316227766016838
#>         f2 <- 1
#>         eta.ke ~ 0.04
#>     })
#>     model({
#>         ke <- tke * exp(eta.ke)
#>         ipre <- 10 * exp(-ke * t)
#>         f2 <- ipre/(ipre + 5)
#>         ipre ~ propF(prop.sd, f2)
#>     })
#> }

Created on 2022-01-16 by the reprex package (v2.0.0)

f2 shouldn't be estimated

Create a function that saves the `rxode2` state

This would at least be any seed information. Code should be checked for any other places that global package values are stored (environments or variables assigned in the rxode2 namespace).

Could be related to #19 and #17

Piping issue -- switching modeled variable in single endpoint models

library(rxode2)
#> rxode2 1.0.0 using 4 threads (see ?getRxThreads)

f <- function() {
  ini({
    tke <- 0.5
    eta.ke ~ 0.04
    prop.sd <- sqrt(0.1)
  })
  model({
    ke <- tke * exp(eta.ke)
    ipre <- 10 * exp(-ke * t)
    f2 <- ipre / (ipre + 5)
    f3 <- f2 * 3
    lipre <- log(ipre)
    ipre ~ prop(prop.sd)
  })
}

f <- rxode2(f)


f %>% model(lipre ~ add(log.add.sd))
#> rxode2 model syntax error:
#> ================================================================================
#> :001:     ke <- tke * exp(eta.ke)
#> :002:     ipre <- 10 * exp(-ke * t)
#> :003:     f2 <- ipre/(ipre + 5)
#> :004:     f3 <- f2 * 3
#> :005: function 'add' is not supported in rxode2:
#>           lipre ~ add(log.add.sd)
#>                   ^~~
#> ================================================================================
#> Error in rxModelVars_(.obj): Evaluation error: syntax errors (see above).

Created on 2022-01-18 by the reprex package (v2.0.0)

Note this can succeed if:

  • Piped content determines it is only an error expression, which is more complicated than what is currently done.
  • Determines if the lhs is defined in the non-error model
  • Determines this is a single end-point model
  • But it should issue a warning that says we are assuming that we are changing the endpoint modeled from ipre to lipre

It would be helpful to have the piping work for the nlmixr focei wang2007 test

Low Priority Code Review Request: Remove unused code

While looking through the tests, I found some areas that appear to have unused code. Specifically, there is code after the last expectation that does not appear to be related to cleanup in the following places. I would appreciate a look in case there is code that can be removed or if there is something that may benefit from an additional comment to clarify the need for the code.

Line numbers will be approximate as PRs are coming that may move things around slightly.

  • test-ifelse.R after about line 170.
  • test-ind-lin.R between lines 122 and 168; mmModel is defined several times without an apparent test.
  • test-ind-lin.R after line 287
  • test-opt-expr.R lines 14 to 21

Unclear Purpose for test-zzzz-rxUse.R

It looks like test-zzzz-rxUse.R builds a package around a model. Is that a necessary test? It fails on Windows 10.

(The underlying question is that I'm uncertain of why rxUse() exists. And the next question is if/how we should test it.)

test-lincmt-solve with seq(0.5, 1, 1.5) only uses a single value

There are 6 loops in test-lincmt-solve.R that have seq(0.5, 1, 1.5) where the result is that the value is only 0.5. I think that the intent is to use c(0.5, 1, 1.5). @mattfidler, can you please take a look and confirm that c() is the intent?

for (rt in seq(0.5, 1, 1.5)) {

for (rt in seq(0.5, 1, 1.5)) {

for (rt in seq(0.5, 1, 1.5)) {

for (dur in seq(0.5, 1, 1.5)) {

for (dur in seq(0.5, 1, 1.5)) {

for (dur in seq(0.5, 1, 1.5)) {

Feature Request: Fix/make silent some compilation warnings

The following code has multiple compilation warnings that would likely be better silenced (or better having a modification of the code generation step so that the warnings aren't generated).

library(rxode2)
#> Warning in dir.create(.tmp, recursive = TRUE): 'C:
#> \Users\BILLDE~1\AppData\Local\Temp\RTMPMW~1\rxode2' already exists
#> rxode2 1.0.0 using 4 threads (see ?getRxThreads)
#>   no cache: create with `rxCreateCache()`
m1 <- rxode2({
  a <- b
  c <- lag(a)
})
#> rx_b51cd538ca59c9b3aad52c94af36b301_x64.c:81: warning: "diff_a1" redefined
#>  #define diff_a1(x) (x - _getParCov(_cSub, _solveData, 0, (&_solveData->subjects[_cSub])->idx - 1))
#>  
#> rx_b51cd538ca59c9b3aad52c94af36b301_x64.c:77: note: this is the location of the previous definition
#>  #define diff_a1(x) _solveData->subjects[_cSub].lhs[0]
#>  
#> rx_b51cd538ca59c9b3aad52c94af36b301_x64.c:82: warning: "diff_a" redefined
#>  #define diff_a(x,y) (x - _getParCov(_cSub, _solveData, 0, (&_solveData->subjects[_cSub])->idx - (y)))
#>  
#> rx_b51cd538ca59c9b3aad52c94af36b301_x64.c:78: note: this is the location of the previous definition
#>  #define diff_a(x,y) _solveData->subjects[_cSub].lhs[0]
#>  
#> rx_b51cd538ca59c9b3aad52c94af36b301_x64.c:85: warning: "lead_a1" redefined
#>  #define lead_a1(x) _getParCov(_cSub, _solveData, 0, (&_solveData->subjects[_cSub])->idx + 1)
#>  
#> rx_b51cd538ca59c9b3aad52c94af36b301_x64.c:75: note: this is the location of the previous definition
#>  #define lead_a1(x) _solveData->subjects[_cSub].lhs[0]
#>  
#> rx_b51cd538ca59c9b3aad52c94af36b301_x64.c:86: warning: "lead_a" redefined
#>  #define lead_a(x, y) _getParCov(_cSub, _solveData, 0, (&_solveData->subjects[_cSub])->idx + (y))
#>  
#> rx_b51cd538ca59c9b3aad52c94af36b301_x64.c:76: note: this is the location of the previous definition
#>  #define lead_a(x,y) _solveData->subjects[_cSub].lhs[0]
#>  
#> rx_b51cd538ca59c9b3aad52c94af36b301_x64.c:87: warning: "lag_a1" redefined
#>  #define lag_a1(x) _getParCov(_cSub, _solveData, 0, (&_solveData->subjects[_cSub])->idx - 1)
#>  
#> rx_b51cd538ca59c9b3aad52c94af36b301_x64.c:79: note: this is the location of the previous definition
#>  #define lag_a1(x) _solveData->subjects[_cSub].lhs[0]
#>  
#> rx_b51cd538ca59c9b3aad52c94af36b301_x64.c:88: warning: "lag_a" redefined
#>  #define lag_a(x,y) _getParCov(_cSub, _solveData, 0, (&_solveData->subjects[_cSub])->idx - (y))
#>  
#> rx_b51cd538ca59c9b3aad52c94af36b301_x64.c:80: note: this is the location of the previous definition
#>  #define lag_a(x, y) _solveData->subjects[_cSub].lhs[0]
#> 

Created on 2022-01-23 by the reprex package (v2.0.1)

rxUse Failure on Windows

TL;DR: Should we skip the rxUse test on Windows?

When running the rxUse()/rxPkg() tests, there is an error on Windows (ref #29). My initial testing found that the error was here:

rxode2/R/rxode2.R

Line 1338 in 2908fc9

dyn.unload(.cDllFile)

And the error was:

Error in dyn.unload(.cDllFile) : 
  shared object 'C:/Users/BILLDE~1/AppData/Local/Temp/RTMPUC~2/RXUSE-~1/rxm/inst/rx/rxm_mod.dll' was not loaded

I got farther when I modified the line above to be try({dyn.unload(.cDllFile)}), but there was a later error that I couldn't directly identify. I'd be a bit worried to wrap the dyn.unload() in try() in a general sense. The function seems a bit ancillary to the main purpose of rxode2, so I'd lean toward ignoring the error on Windows. And possibly, we could give a warning that the function may not work on Windows for any users.

@mattfidler, What are your thoughts?

Check that it looks for the right values

# This works
library(nlmixr)
one.cmt <- function() {
    ini({
      tka <- 0.5
      tcl <- log(c(0, 2.7, 100))
      tv <- 3.45; label("log V")
      eta.ka ~ 0.6
      eta.cl ~ 0.3
      eta.v ~ 0.1
      add.sd <- 0.7
    })
    model({
      ka <- exp(tka + eta.ka)
      cl <- exp(tcl + eta.cl)
      v <- exp(tv + eta.v)
      linCmt() ~ add(add.sd)
    })
}
inka <- 5
fit <- nlmixr(one.cmt, theo_sd, est="foce") %>% ini(tka=fix(inka))
fit
rm(inka)

# This doesn't work because the inka object is defined within the function and not globally
fitfunc <- function(){
  one.cmt <- function() {
    ini({
      tka <- 0.5
      tcl <- log(c(0, 2.7, 100))
      tv <- 3.45; label("log V")
      eta.ka ~ 0.6
      eta.cl ~ 0.3
      eta.v ~ 0.1
      add.sd <- 0.7
    })
    model({
      ka <- exp(tka + eta.ka)
      cl <- exp(tcl + eta.cl)
      v <- exp(tv + eta.v)
      linCmt() ~ add(add.sd)
    })
  }
  inka <- 5
  fit <- nlmixr(one.cmt, theo_sd, est="foce") %>% ini(tka=fix(inka))
  fit
}
fitfunc()

add(lhs) not coded correctly for focei, but you can see it with nlmixr2

library(nlmixr2)
#> detected new version of nlmixr2, cleaning rxode2 cache

f <- function() {
  ini({
    tke <- 0.5
    eta.ke ~ 0.04
    prop.sd <- sqrt(0.1)
  })
  model({
    ke <- tke * exp(eta.ke)
    ipre <- 10 * exp(-ke * t)
    f2 <- ipre / (ipre + 5)
    f3 <- f2 * 3
    lipre <- log(ipre)
    ipre ~ prop(prop.sd)
  })
}

f %>%
  model(ipre ~ add(add.sd)) ->
  tmp1

tmp1$foceiModel0
#> rxModelVars({
#>     tke <- THETA[1]
#>     add.sd <- THETA[2]
#>     eta.ke <- ETA[1]
#>     ke <- tke * exp(eta.ke)
#>     ipre <- 10 * exp(-ke * t)
#>     f2 <- ipre/(ipre + 5)
#>     f3 <- f2 * 3
#>     lipre <- log(ipre)
#>     rx_yj_ ~ 2
#>     rx_lambda_ ~ 1
#>     rx_low_ ~ 0
#>     rx_hi_ ~ 1
#>     rx_pred_f_ ~ ipre
#>     rx_pred_ ~ rx_pred_f_
#>     rx_r_ ~ (add.sd)^2
#> })

f %>%
  model(ipre ~ add(f2)) ->
  tmp2

tmp2$foceiModel0
#> rxModelVars({
#>     tke <- THETA[1]
#>     eta.ke <- ETA[1]
#>     ke <- tke * exp(eta.ke)
#>     ipre <- 10 * exp(-ke * t)
#>     f2 <- ipre/(ipre + 5)
#>     f3 <- f2 * 3
#>     lipre <- log(ipre)
#>     rx_yj_ ~ 2
#>     rx_lambda_ ~ 1
#>     rx_low_ ~ 0
#>     rx_hi_ ~ 1
#>     rx_pred_f_ ~ ipre
#>     rx_pred_ ~ rx_pred_f_
#>     rx_r_ ~ f2
#> })

Created on 2022-01-21 by the reprex package (v2.0.0)

Switch Default Branch on Codecov.io

Currently, I think that the default branch on codecov.io is "master" when it should be "main". That will fix the badge image at the top of the Readme.md file. (The same is appears to be needed for lotri and nlmixr2.)

To make the change, go to https://app.codecov.io/gh/nlmixr2/rxode2/settings and then change the default branch to main. (I think that should work; that's how it looks in a different repo for me.)

test-random.R Has Multiple Issues on Windows

The log of output is below (I plan to take a shot at fixing it, but it is going to take different/more work than the other simpler fixes in #19.

==> Testing R file using 'testthat'

i Loading rxode2
rxode2 1.0.0 using 4 threads (see ?getRxThreads)
  no cache: create with `rxCreateCache()`

== Testing test-random.R =======================================================
[ FAIL 0 | WARN 0 | SKIP 0 | PASS 0 ][====|====|===
=|====|====|====|====|====|====|====] 0:00:00 
[ FAIL 6 | WARN 3 | SKIP 0 | PASS 1 ][====|====|====|====|====|====|===
=|====|====|====] 0:00:00 
[ FAIL 6 | WARN 3 | SKIP 0 | PASS 8 ]rxode2 model syntax error:
================================================================================
:001: 'rinorm'/'rxnorm'/'rnorm' takes 0-2 arguments 'rxnorm(mean, sd)':
          x4 <- rnorm(a, b, c, d)
                ^~~~~
================================================================================
[ FAIL 6 | WARN 3 | SKIP 0 | PASS 13 ]rxode2 model syntax error:
================================================================================
:001: 'rinormV'/'rxnormV'/'rnormV' takes 0-2 arguments 'rxnormV(mean, sd)':
          x4 <- rnormV(a, b, c, d)
                ^~~~~~
================================================================================
[ FAIL 9 | WARN 5 | SKIP 0 | PASS 21 ]rxode2 model syntax error:
================================================================================
:001: 'ricauchy'/'rxcauchy'/'rcauchy' takes 0-2 arguments 'rxcauchy(location, scale)':
          x4 <- rcauchy(a, b, c, d)
                ^~~~~~~
================================================================================
[ FAIL 13 | WARN 7 | SKIP 0 | PASS 25 ]rxode2 model syntax error:
================================================================================
:001: 'rchisq' takes 1 argument:
          x1 <- rchisq()
                       ^
================================================================================
rxode2 model syntax error:
================================================================================
:001: 'rchisq' takes 1 argument:
          x1 <- rchisq(a, b)
                ^~~~~~
================================================================================
[ FAIL 17 | WARN 9 | SKIP 0 | PASS 30 ]rxode2 model syntax error:
================================================================================
:001: 'rexp' takes 0-1 argument:
          x1 <- rexp(a, b)
                ^~~~
================================================================================
[ FAIL 21 | WARN 11 | SKIP 0 | PASS 34 ]rxode2 model syntax error:
================================================================================
:001: 'rif'/'rxf'/'rf' takes 2 arguments 'rxf(df1, df2)':
          x1 <- rf(a, b, c)
                ^~
================================================================================
[ FAIL 21 | WARN 11 | SKIP 0 | PASS 35 ]rxode2 model syntax error:
================================================================================
:001: 'rif'/'rxf'/'rf' takes 2 arguments 'rxf(df1, df2)':
          x1 <- rf(a)
                   ^
================================================================================
[ FAIL 21 | WARN 11 | SKIP 0 | PASS 36 ]rxode2 model syntax error:
================================================================================
:001: 'rif'/'rxf'/'rf' takes 2 arguments 'rxf(df1, df2)':
          x1 <- rf()
                   ^
================================================================================
[ FAIL 23 | WARN 11 | SKIP 0 | PASS 40 ]rxode2 model syntax error:
================================================================================
:001: 'rigamma'/'rxgamma'/'rgamma' takes 1-2 arguments 'rxgamma(shape, rate)':
          x1 <- rgamma(a, b, c)
                ^~~~~~
================================================================================
[ FAIL 23 | WARN 11 | SKIP 0 | PASS 41 ]rxode2 model syntax error:
================================================================================
:001: 'rigamma'/'rxgamma'/'rgamma' takes 1-2 arguments 'rxgamma(shape, rate)':
          x1 <- rgamma()
                       ^
================================================================================
[ FAIL 27 | WARN 13 | SKIP 0 | PASS 45 ]rxode2 model syntax error:
================================================================================
:001: 'ribeta'/'rxbeta'/'rbeta' takes 2 arguments 'rxbeta(shape1, shape2)':
          x1 <- rbeta(a, b, c)
                ^~~~~
================================================================================
[ FAIL 27 | WARN 13 | SKIP 0 | PASS 46 ]rxode2 model syntax error:
================================================================================
:001: 'ribeta'/'rxbeta'/'rbeta' takes 2 arguments 'rxbeta(shape1, shape2)':
          x1 <- rbeta(a)
                      ^
================================================================================
[ FAIL 27 | WARN 13 | SKIP 0 | PASS 47 ]rxode2 model syntax error:
================================================================================
:001: 'ribeta'/'rxbeta'/'rbeta' takes 2 arguments 'rxbeta(shape1, shape2)':
          x1 <- rbeta()
                      ^
================================================================================
[ FAIL 28 | WARN 13 | SKIP 0 | PASS 50 ]rxode2 model syntax error:
================================================================================
:001: 'rigeom'/'rxgeom'/'rgeom' takes 1 argument 'rxgeom(prob)':
          x1 <- rgeom()
                      ^
================================================================================
[ FAIL 28 | WARN 13 | SKIP 0 | PASS 52 ]rxode2 model syntax error:
================================================================================
:001: 'rigeom'/'rxgeom'/'rgeom' takes 1 argument 'rxgeom(prob)':
          x1 <- rgeom(a, b)
                ^~~~~
================================================================================
[ FAIL 32 | WARN 15 | SKIP 0 | PASS 56 ]rxode2 model syntax error:
================================================================================
:001: 'ripois'/'rxpois'/'rpois' takes 1 argument 'rxpois(lambda)':
          x1 <- rpois()
                      ^
================================================================================
[ FAIL 32 | WARN 15 | SKIP 0 | PASS 57 ]rxode2 model syntax error:
================================================================================
:001: 'ripois'/'rxpois'/'rpois' takes 1 argument 'rxpois(lambda)':
          x1 <- rxpois(a, b)
                ^~~~~~
================================================================================
[ FAIL 36 | WARN 17 | SKIP 0 | PASS 61 ]rxode2 model syntax error:
================================================================================
:001: 'rt' takes 1 argument:
          x1 <- rt()
                   ^
================================================================================
[ FAIL 36 | WARN 17 | SKIP 0 | PASS 62 ]rxode2 model syntax error:
================================================================================
:001: 'rt' takes 1 argument:
          x1 <- rt(a, b)
                ^~
================================================================================
[====|====|====|==
[ FAIL 36 | WARN 18 | SKIP 0 | PASS 63 ]==|====|====|====|====|====|====] 0:00:00 
[ FAIL 42 | WARN 20 | SKIP 0 | PASS 63 ][====|====|====|====|====
[ FAIL 42 | WARN 20 | SKIP 0 | PASS 64 ]|====|====|====|====|====] 0:00:00 
[ FAIL 42 | WARN 20 | SKIP 0 | PASS 71 ]rxode2 model syntax error:
================================================================================
:001: 'riunif'/'rxunif'/'runif' takes 0-2 arguments 'rxunif(min, max)':
          x4 <- runif(a, b, c, d)
                ^~~~~
================================================================================
[ FAIL 46 | WARN 22 | SKIP 0 | PASS 76 ]rxode2 model syntax error:
================================================================================
:001: 'riweibull'/'rxweibull'/'rweibull' takes 1-2 arguments 'rxweibull(shape, scale)':
          x1 <- rweibull(a, b, c)
                ^~~~~~~~
================================================================================
[ FAIL 46 | WARN 22 | SKIP 0 | PASS 77 ]rxode2 model syntax error:
================================================================================
:001: 'riweibull'/'rxweibull'/'rweibull' takes 1-2 arguments 'rxweibull(shape, scale)':
          x1 <- rweibull()
                         ^
================================================================================
[ FAIL 86 | WARN 22 | SKIP 0 | PASS 174 ]

-- Warning (test-random.R:26:7): rnorm -----------------------------------------
argument is not numeric or logical: returning NA
Backtrace:
 1. testthat::expect_equal(mean(f$x1), 0, tolerance = 0.01) test-random.R:26:6
 5. base::mean.default(f$x1)

-- Failure (test-random.R:26:7): rnorm -----------------------------------------
mean(f$x1) (`actual`) not equal to 0 (`expected`).

  `actual`: NA
`expected`:  0

-- Failure (test-random.R:27:7): rnorm -----------------------------------------
sd(f$x1) (`actual`) not equal to 1 (`expected`).

  `actual`: NA
`expected`:  1

-- Warning (test-random.R:29:7): rnorm -----------------------------------------
argument is not numeric or logical: returning NA
Backtrace:
 1. testthat::expect_equal(mean(f$x2), 3, tolerance = 0.01) test-random.R:29:6
 5. base::mean.default(f$x2)

-- Failure (test-random.R:29:7): rnorm -----------------------------------------
mean(f$x2) (`actual`) not equal to 3 (`expected`).

  `actual`: NA
`expected`:  3

-- Failure (test-random.R:30:7): rnorm -----------------------------------------
sd(f$x1) (`actual`) not equal to 1 (`expected`).

  `actual`: NA
`expected`:  1

-- Warning (test-random.R:33:7): rnorm -----------------------------------------
argument is not numeric or logical: returning NA
Backtrace:
 1. testthat::expect_equal(mean(f$x3), 5, tolerance = 0.01) test-random.R:33:6
 5. base::mean.default(f$x3)

-- Failure (test-random.R:33:7): rnorm -----------------------------------------
mean(f$x3) (`actual`) not equal to 5 (`expected`).

  `actual`: NA
`expected`:  5

-- Failure (test-random.R:34:7): rnorm -----------------------------------------
sd(f$x3) (`actual`) not equal to 2 (`expected`).

  `actual`: NA
`expected`:  2

-- Warning (test-random.R:121:7): rbinom ---------------------------------------
no non-missing arguments to max; returning -Inf
Backtrace:
 1. testthat::expect_equal(max(f$x1), 4) test-random.R:121:6
 2. testthat::quasi_label(enquo(object), label, arg = "object")
 3. rlang::eval_bare(expr, quo_get_env(quo))

-- Failure (test-random.R:121:7): rbinom ---------------------------------------
max(f$x1) (`actual`) not equal to 4 (`expected`).

  `actual`: -Inf
`expected`:    4

-- Warning (test-random.R:122:7): rbinom ---------------------------------------
no non-missing arguments to min; returning Inf
Backtrace:
 1. testthat::expect_equal(min(f$x1), 0) test-random.R:122:6
 2. testthat::quasi_label(enquo(object), label, arg = "object")
 3. rlang::eval_bare(expr, quo_get_env(quo))

-- Failure (test-random.R:122:7): rbinom ---------------------------------------
min(f$x1) (`actual`) not equal to 0 (`expected`).

  `actual`: Inf
`expected`:   0

-- Error (test-random.R:123:7): rbinom -----------------------------------------
Error in `round(f$x1)`: non-numeric argument to mathematical function
Backtrace:
 1. testthat::expect_true(all(round(f$x1) == f$x1)) test-random.R:123:6
 2. testthat::quasi_label(enquo(object), label, arg = "object")
 3. rlang::eval_bare(expr, quo_get_env(quo))

-- Warning (test-random.R:210:7): rchisq ---------------------------------------
argument is not numeric or logical: returning NA
Backtrace:
 1. testthat::expect_equal(mean(f$x1), 15, tolerance = 0.1) test-random.R:210:6
 5. base::mean.default(f$x1)

-- Failure (test-random.R:210:7): rchisq ---------------------------------------
mean(f$x1) (`actual`) not equal to 15 (`expected`).

  `actual`: NA
`expected`: 15

-- Failure (test-random.R:211:7): rchisq ---------------------------------------
sd(f$x1) (`actual`) not equal to sqrt(2 * 15) (`expected`).

  `actual`: NA
`expected`:  5

-- Warning (test-random.R:213:7): rchisq ---------------------------------------
argument is not numeric or logical: returning NA
Backtrace:
 1. testthat::expect_equal(mean(f$x2), 20, tolerance = 0.1) test-random.R:213:6
 5. base::mean.default(f$x2)

-- Failure (test-random.R:213:7): rchisq ---------------------------------------
mean(f$x2) (`actual`) not equal to 20 (`expected`).

  `actual`: NA
`expected`: 20

-- Failure (test-random.R:214:7): rchisq ---------------------------------------
sd(f$x2) (`actual`) not equal to sqrt(2 * 20) (`expected`).

  `actual`: NA
`expected`:  6

-- Warning (test-random.R:255:7): rexp tests -----------------------------------
argument is not numeric or logical: returning NA
Backtrace:
 1. testthat::expect_equal(mean(f$x1), 2, tolerance = 0.1) test-random.R:255:6
 5. base::mean.default(f$x1)

-- Failure (test-random.R:255:7): rexp tests -----------------------------------
mean(f$x1) (`actual`) not equal to 2 (`expected`).

  `actual`: NA
`expected`:  2

-- Failure (test-random.R:256:7): rexp tests -----------------------------------
sd(f$x1) (`actual`) not equal to sqrt(1/(0.5 * 0.5)) (`expected`).

  `actual`: NA
`expected`:  2

-- Warning (test-random.R:258:7): rexp tests -----------------------------------
argument is not numeric or logical: returning NA
Backtrace:
 1. testthat::expect_equal(mean(f$x2), 1, tolerance = 0.1) test-random.R:258:6
 5. base::mean.default(f$x2)

-- Failure (test-random.R:258:7): rexp tests -----------------------------------
mean(f$x2) (`actual`) not equal to 1 (`expected`).

  `actual`: NA
`expected`:  1

-- Failure (test-random.R:259:7): rexp tests -----------------------------------
sd(f$x2) (`actual`) not equal to 1 (`expected`).

  `actual`: NA
`expected`:  1

-- Warning (test-random.R:303:7): rf tests -------------------------------------
argument is not numeric or logical: returning NA
Backtrace:
 1. testthat::expect_equal(mean(f$x1), mf(20), tolerance = 0.01) test-random.R:303:6
 5. base::mean.default(f$x1)

-- Failure (test-random.R:303:7): rf tests -------------------------------------
mean(f$x1) (`actual`) not equal to mf(20) (`expected`).

  `actual`: NA
`expected`:  1

-- Failure (test-random.R:304:7): rf tests -------------------------------------
sd(f$x1) (`actual`) not equal to sf(10, 20) (`expected`).

  `actual`: NA
`expected`:  1

-- Warning (test-random.R:306:7): rf tests -------------------------------------
argument is not numeric or logical: returning NA
Backtrace:
 1. testthat::expect_equal(mean(f$x2), mf(40), tolerance = 0.01) test-random.R:306:6
 5. base::mean.default(f$x2)

-- Failure (test-random.R:306:7): rf tests -------------------------------------
mean(f$x2) (`actual`) not equal to mf(40) (`expected`).

  `actual`: NA
`expected`:  1

-- Failure (test-random.R:307:7): rf tests -------------------------------------
sd(f$x2) (`actual`) not equal to sf(30, 40) (`expected`).

  `actual`: NA
`expected`:  0

-- Failure (test-random.R:355:7): rgamma tests ---------------------------------
sd(f$x1) (`actual`) not equal to sgamma(9, 0.5) (`expected`).

  `actual`: NA
`expected`:  6

-- Failure (test-random.R:357:7): rgamma tests ---------------------------------
sd(f$x2) (`actual`) not equal to sgamma(7.5) (`expected`).

  `actual`: NA
`expected`:  3

-- Warning (test-random.R:405:7): rbeta tests ----------------------------------
argument is not numeric or logical: returning NA
Backtrace:
 1. testthat::expect_equal(mean(f$x1), mbeta(2, 5), tolerance = 0.01) test-random.R:405:6
 5. base::mean.default(f$x1)

-- Failure (test-random.R:405:7): rbeta tests ----------------------------------
mean(f$x1) (`actual`) not equal to mbeta(2, 5) (`expected`).

  `actual`: NA
`expected`:  0

-- Failure (test-random.R:406:7): rbeta tests ----------------------------------
sd(f$x1) (`actual`) not equal to sbeta(2, 5) (`expected`).

  `actual`: NA
`expected`:  0

-- Warning (test-random.R:408:7): rbeta tests ----------------------------------
argument is not numeric or logical: returning NA
Backtrace:
 1. testthat::expect_equal(mean(f$x2), mbeta(2, 2), tolerance = 0.01) test-random.R:408:6
 5. base::mean.default(f$x2)

-- Failure (test-random.R:408:7): rbeta tests ----------------------------------
mean(f$x2) (`actual`) not equal to mbeta(2, 2) (`expected`).

  `actual`: NA
`expected`:  0

-- Failure (test-random.R:409:7): rbeta tests ----------------------------------
sd(f$x2) (`actual`) not equal to sbeta(2, 2) (`expected`).

  `actual`: NA
`expected`:  0

-- Failure (test-random.R:454:7): rgeom tests ----------------------------------
median(f$x2) (`actual`) not equal to -ceiling(1/log2(1 - 0.1)) (`expected`).

`actual` is NULL
`expected` is a double vector (6)

-- Warning (test-random.R:491:7): rpois ----------------------------------------
argument is not numeric or logical: returning NA
Backtrace:
 1. testthat::expect_equal(mean(f$x1), 1, tolerance = 0.01) test-random.R:491:6
 5. base::mean.default(f$x1)

-- Failure (test-random.R:491:7): rpois ----------------------------------------
mean(f$x1) (`actual`) not equal to 1 (`expected`).

  `actual`: NA
`expected`:  1

-- Failure (test-random.R:492:7): rpois ----------------------------------------
sd(f$x1) (`actual`) not equal to 1 (`expected`).

  `actual`: NA
`expected`:  1

-- Warning (test-random.R:494:7): rpois ----------------------------------------
argument is not numeric or logical: returning NA
Backtrace:
 1. testthat::expect_equal(mean(f$x2), 2, tolerance = 0.01) test-random.R:494:6
 5. base::mean.default(f$x2)

-- Failure (test-random.R:494:7): rpois ----------------------------------------
mean(f$x2) (`actual`) not equal to 2 (`expected`).

  `actual`: NA
`expected`:  2

-- Failure (test-random.R:495:7): rpois ----------------------------------------
sd(f$x2) (`actual`) not equal to sqrt(2) (`expected`).

  `actual`: NA
`expected`:  1

-- Warning (test-random.R:534:7): rt -------------------------------------------
argument is not numeric or logical: returning NA
Backtrace:
 1. testthat::expect_equal(mean(f$x1), 0, tolerance = 0.1) test-random.R:534:6
 5. base::mean.default(f$x1)

-- Failure (test-random.R:534:7): rt -------------------------------------------
mean(f$x1) (`actual`) not equal to 0 (`expected`).

  `actual`: NA
`expected`:  0

-- Failure (test-random.R:535:7): rt -------------------------------------------
sd(f$x1) (`actual`) not equal to sqrt(15/(15 - 2)) (`expected`).

  `actual`: NA
`expected`:  1

-- Warning (test-random.R:537:7): rt -------------------------------------------
argument is not numeric or logical: returning NA
Backtrace:
 1. testthat::expect_equal(mean(f$x2), 0, tolerance = 0.1) test-random.R:537:6
 5. base::mean.default(f$x2)

-- Failure (test-random.R:537:7): rt -------------------------------------------
mean(f$x2) (`actual`) not equal to 0 (`expected`).

  `actual`: NA
`expected`:  0

-- Failure (test-random.R:538:7): rt -------------------------------------------
sd(f$x2) (`actual`) not equal to sqrt(20/(20 - 2)) (`expected`).

  `actual`: NA
`expected`:  1

-- Warning (test-random.R:582:7): runif ----------------------------------------
argument is not numeric or logical: returning NA
Backtrace:
 1. testthat::expect_equal(mean(f$x1), 0.5, tolerance = 0.01) test-random.R:582:6
 5. base::mean.default(f$x1)

-- Failure (test-random.R:582:7): runif ----------------------------------------
mean(f$x1) (`actual`) not equal to 0.5 (`expected`).

  `actual`: NA
`expected`:  0

-- Failure (test-random.R:583:7): runif ----------------------------------------
sd(f$x1) (`actual`) not equal to sqrt(1/12) (`expected`).

  `actual`: NA
`expected`:  0

-- Warning (test-random.R:585:7): runif ----------------------------------------
argument is not numeric or logical: returning NA
Backtrace:
 1. testthat::expect_equal(mean(f$x2), 0.5 * (0.5 + 1), tolerance = 0.01) test-random.R:585:6
 5. base::mean.default(f$x2)

-- Failure (test-random.R:585:7): runif ----------------------------------------
mean(f$x2) (`actual`) not equal to 0.5 * (0.5 + 1) (`expected`).

  `actual`: NA
`expected`:  1

-- Failure (test-random.R:586:7): runif ----------------------------------------
sd(f$x2) (`actual`) not equal to sqrt((1 - 0.5)^2/12) (`expected`).

  `actual`: NA
`expected`:  0

-- Warning (test-random.R:588:7): runif ----------------------------------------
argument is not numeric or logical: returning NA
Backtrace:
 1. testthat::expect_equal(mean(f$x3), 0.5 * (0.25 + 0.75), tolerance = 0.01) test-random.R:588:6
 5. base::mean.default(f$x3)

-- Failure (test-random.R:588:7): runif ----------------------------------------
mean(f$x3) (`actual`) not equal to 0.5 * (0.25 + 0.75) (`expected`).

  `actual`: NA
`expected`:  0

-- Failure (test-random.R:589:7): runif ----------------------------------------
sd(f$x3) (`actual`) not equal to sqrt((0.75 - 0.25)^2/12) (`expected`).

  `actual`: NA
`expected`:  0

-- Warning (test-random.R:648:7): rweibull tests -------------------------------
argument is not numeric or logical: returning NA
Backtrace:
 1. testthat::expect_equal(mean(f$x1), mweibull(9, 0.5), tolerance = 0.01) test-random.R:648:6
 5. base::mean.default(f$x1)

-- Failure (test-random.R:648:7): rweibull tests -------------------------------
mean(f$x1) (`actual`) not equal to mweibull(9, 0.5) (`expected`).

  `actual`: NA
`expected`:  0

-- Failure (test-random.R:649:7): rweibull tests -------------------------------
sd(f$x1) (`actual`) not equal to sweibull(9, 0.5) (`expected`).

  `actual`: NA
`expected`:  0

-- Warning (test-random.R:651:7): rweibull tests -------------------------------
argument is not numeric or logical: returning NA
Backtrace:
 1. testthat::expect_equal(mean(f$x2), mweibull(7.5), tolerance = 0.01) test-random.R:651:6
 5. base::mean.default(f$x2)

-- Failure (test-random.R:651:7): rweibull tests -------------------------------
mean(f$x2) (`actual`) not equal to mweibull(7.5) (`expected`).

  `actual`: NA
`expected`:  1

-- Failure (test-random.R:652:7): rweibull tests -------------------------------
sd(f$x2) (`actual`) not equal to sweibull(7.5) (`expected`).

  `actual`: NA
`expected`:  0

-- Failure (test-random.R:722:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:722:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:722:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:722:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:722:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:722:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:722:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:722:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:722:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:722:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:722:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:722:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:722:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:722:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:722:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:722:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:722:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:722:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:722:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:722:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:766:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:766:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:766:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:766:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:766:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:766:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:766:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:766:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:766:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:766:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:766:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:766:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:766:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:766:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:766:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:766:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:766:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:766:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:766:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

-- Failure (test-random.R:766:9): individual random variable tests -------------
sum(duplicated(paste0(f$id, f[[paste0("x", i)]]))) (`actual`) not equal to 5 (`expected`).

  `actual`: 0
`expected`: 5

[ FAIL 86 | WARN 22 | SKIP 0 | PASS 174 ]

Test complete

Low and Hi not being captured correctly by `logitNorm(NA)`

library(nlmixr2)
f <- function() {
  ini({
    tke <- 0.5
    eta.ke ~ 0.04
    prop.sd <- sqrt(0.1)
  })
  model({
    ke <- tke * exp(eta.ke)
    ipre <- 10 * exp(-ke * t)
    f2 <- ipre / (ipre + 5)
    f3 <- f2 * 3
    lipre <- log(ipre)
    ipre ~ prop(prop.sd)
  })
}

trans <- function(f) {
  f %>% model(ipre ~ logitNorm(NA, 0, 12) + prop(prop.sd)) %>%
    ini(prop.sd=sqrt(0.1))
}

trans(f)$foceiModel0
#> rxModelVars({
#>     tke <- THETA[1]
#>     prop.sd <- THETA[2]
#>     eta.ke <- ETA[1]
#>     ke <- tke * exp(eta.ke)
#>     ipre <- 10 * exp(-ke * t)
#>     f2 <- ipre/(ipre + 5)
#>     f3 <- f2 * 3
#>     lipre <- log(ipre)
#>     rx_yj_ ~ 4
#>     rx_lambda_ ~ 1
#>     rx_low_ ~ -Inf
#>     rx_hi_ ~ Inf
#>     rx_pred_f_ ~ ipre
#>     rx_pred_ ~ rxTBS(rx_pred_f_, rx_lambda_, rx_yj_, rx_low_, 
#>         rx_hi_)
#>     rx_r_ ~ (rx_pred_f_ * prop.sd)^2
#> })

Created on 2022-01-27 by the reprex package (v2.0.0)

The function rxUnloadAll() is defined twice in utils.R

FYI, I found this while doing some documentation clean-ups, so please do not fix this until you've merged PR #5.

The first definition:

rxode2/R/utils.R

Lines 52 to 86 in d1bac25

#' Unloads all rxode2 compiled DLLs
#'
#' @return List of rxode2 dlls still loaded
#'
#' @return boolean of if all rxode2 dlls have been unloaded
#'
#' @examples
#'
#' print(rxUnloadAll())
#' @export
rxUnloadAll <- function() {
.Call(`_rxode2_rxUnloadAll_`) # nolint
.dll <- getLoadedDLLs()
.n <- names(.dll)
.n <- .n[regexpr("^rx_[a-f0-9]{32}", .n) != -1]
.ret <- lapply(.n, function(rx) {
.cur <- .dll[[rx]]
class(.cur) <- NULL
.num <- .rxModels[[.cur$path]]
if (is.null(.num)) {
dyn.unload(.cur$path)
return(NULL)
} else if (identical(.num, 0L)) {
dyn.unload(.cur$path)
return(NULL)
} else {
return(.cur$path)
}
})
if (length(.ret) == 0) {
return(invisible(.ret))
}
.ret <- .ret[[!is.null(.ret)]]
return(invisible(.ret))
}

The second definition:

rxode2/R/utils.R

Lines 995 to 999 in d1bac25

#' @export
#' @rdname rxUnloadAll_
rxUnloadAll <- function() {
try(rxUnloadAll_(), silent = TRUE)
}

Load Failure with $ syntax

This line gives an error when run automatically but not when run manually. Could there be a race condition for creating or deleting the file? (Putting Sys.sleep(1) just above it didn't fix the problem.)

expect_true(file.exists(dll))

This is with the current github version on Windows.

Questions During Test Update PR Generation

I'm currently working on a test update to switch to testthat edition 3 and to try to make the tests silent when successful.

During that, I have a few questions:

  1. Similar to the suggestion in nlmixr2, I think it would be helpful and simplifying to switch the testing to remove the rxode2Test function. Do you agree?
  2. There are a bunch of calls like .rx <- loadNamespace("rxode2"). Would it be okay to switch all of those to be rxode2::: instead of .rx$ to make it a bit clearer what is happening in the tests? But, I'm not certain that all the .rx$ calls are all just doing the same as :::. I don't think it could be a search-and-replace simple switch.
  3. Many of the tests reset the random number generator with set.seed(). I think that it would be better to use withr::with_seed(). Do you agree?
  4. Longer-term, I think it would be helpful to move the tests like test-rxode-issue-050.R to be in a test file that points to the function being tested. Do you agree with that one?
  5. Several tests suggest that they require the units library. Do you know if the units library is really required?
  6. When running tests in parallel, they tend to stop because of "rxode2 already building model, waiting for lock file removal". Is there a way to make this not an error or less strict? I can imagine using nlmixrtargets in a way where multiple models may be built simultaneously, too. (Though, I've also had some places where I've made errors in updating the testing, so maybe this is a non-issue.)

Minor documentation generation issue for .minfo

When building the documentation, there is a warning:

Warning messages:
1: .minfo.Rd is missing name/title. Skipping

I think that it is related to r-lib/roxygen2#1286. It's overall minor, but I wanted to tag it here to track the link to roxygen2 and so that we can confirm that it is fixed when that is fixed (or when they give correction info over there).

Shiny generation error

I don't have shiny installed on my test system (yet?). And, when running devtools::check(), I got the following error. I think that the simplest fix would be three-fold:

  1. Perform a requireNamespace("shiny") at the beginning of genShinyApp.template(), and issue a warning and bail if it's not present.
  2. Consider wrapping the example in a \dontrun instead of just a \donttest within the @example section of genShinyApp.template() help.
  3. (Longer term and staying true to my theme...): move the function to a separate package.
E  checking examples with --run-donttest (5.5s)
   Running examples in ‘rxode2-Ex.R’ failed
   The error most likely occurred in:

   > base::assign(".ptime", proc.time(), pos = "CheckExEnv")
   > ### Name: genShinyApp.template
   > ### Title: Generate an example (template) of a dosing regimen shiny app
   > ### Aliases: genShinyApp.template write.template.server write.template.ui
   > ### Keywords: nonlinear simulation
   >
   > ### ** Examples
   >
   > ## No test:
   > # create the shiny app example (template)
   > genShinyApp.template(appDir = "myapp")

   Generating an example (template) for a dosing regimen shiny app

   Using the following PK/PD model:
      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;

   Translating the PK/PD ODE model into C, compiling, etc.


   Parameters and their values:
        KA      CL      V2       Q      V3     Kin    Kout    EC50
     0.294  18.600  40.200  10.500 297.000   1.000   1.000 200.000

   Initial values in each compartment:
   depot centr  pari   eff
       0     0     0     1

Warning in sprintf(appDir, fmt = "\n      #\n      # Dosing regimen template generated by rxode2::genShinyApp.template()\n      #\n\n      debug = TRUE\n      #wd = sprintf(\"%%s/../\", getwd())\n      #setwd(wd)\n\n      # Server inputs: Dose, dosing regimen, dosing frequency,\n      # dosing cycle definition, number of dosing cycles\n\n      library(shiny)\n      library(rxode2)\n\n      # read objects from \"rx_shiny_data.rda\" in the  AppDir folder,\n      # objects include, mod1, params, inits, method, atol, rtol.]\n\n      load(\"./rx_shiny_data.rda\")\n      if (!rxDynLoad(mod1)) mod1 <- rxode2(mod1, modName=\"mod1\")\n      # Define server logic\n      shinyServer(function(input, output) {\n\n        get.cp <- reactive({\n          ds <- input$Dose\n          reg <- switch(input$regimen, \"QD\"=1, \"BID\"=2)\n          cyc <- switch(input$cycle,\n              \"continous\"=c(7,0),\n              \"1wkon 1wkoff\"=c(7,7),   Warning in sprintf(appDir, fmt = "\n      #\n      # Dosing regimen template generated by rxode2::genShinyApp.template()\n      #\n\n      debug = TRUE\n      #wd = sprintf(\"%%s/../\", getwd())\n      #setwd(wd)\n\n      # Server inputs: Dose, dosing regimen, dosing frequency,\n      # dosing cycle definition, number of dosing cycles\n\n      library(shiny)\n      library(rxode2)\n\n      # read objects from \"rx_shiny_data.rda\" in the  AppDir folder,\n      # objects include, mod1, params, inits, method, atol, rtol.]\n\n      load(\"./rx_shiny_data.rda\")\n      if (!rxDynLoad(mod1)) mod1 <- rxode2(mod1, modName=\"mod1\")\n      # Define server logic\n      shinyServer(function(input, output) {\n\n        get.cp <- reactive({\n          ds <- input$Dose\n          reg <- switch(input$regimen, \"QD\"=1, \"BID\"=2)\n          cyc <- switch(input$cycle,\n              \"continous\"=c(7,0),\n              \"1wkon 1wkoff\"=c(7,7),\n              \"2wkon 1wkoff\"=c(14,7),\n              \"3wkon 1wkoff\"=c(21,7)\n          )\n          cyc <- rep(1:0, cyc)\n          ncyc <- input$ncyc\n          lcyc <- length(cyc)\n\n          ev <- eventTable()\n          for (i in 1:ncyc) ev$add.dosing(\n              dose=ds,\n              nbr.doses=sum(cyc)*reg,\n              dosing.interval=24/reg,\n              start.time=(i-1)*lcyc*24\n          )\n          ev$get.EventTable()\n          ev$add.sampling(0:(ncyc*lcyc*24))\n\n          mod1$solve(params, ev, inits, method=method, atol=atol, rtol=rtol)\n        })\n\n\n        output$summary <- renderPrint({\n          x <- get.cp()\n          print(x[1:4,])\n          if (debug) print(getwd())\n        })\n\n        output$CpPlot <- renderPlot({\n          x <- get.cp()\n          cmp <- input$compartment\n          plot(x[,c(\"time\", cmp)], xlab = \"Time\", ylab = \"Drug amount\",\n               main = cmp, type = \"l\")\n        })\n      })\n   ",  :
     2 arguments not used by format '
         #
         # Dosing regimen template generated by rxode2::genShinyApp.template()
         #

         debug = TRUE
         #wd = sprintf("%%s/../", getwd())
         #setwd(wd)

         # Server inputs: Dose, dosing regimen, dosing frequency,
         # dosing cycle definition, number of dosing cycles

         library(shiny)
         library(rxode2)

         # read objects from "rx_shiny_data.rda" in the  AppDir folder,
         # objects include, mod1, params, inits, method, atol, rtol.]

         load("./rx_shiny_data.rda")
         if (!rxDynLoad(mod1)) mod1 <- rxode2(mod1, modName="mod1")
         # Define server logic
         shinyServer(function(input, output) {

           get.cp <- reactive({
             ds <- input$Dose
             reg <- switch(input$regimen, "QD"=1, "BID"=2)
             cyc <- switch(input$cycle,
                 "continous"=c(7,0),
                 "1wkon 1wkoff"=c(7,7),
                 "2wkon 1wkoff"=c(14,7),
                 "3wkon 1wkoff"=c(21,7)
             )
             cyc <- [... truncated]
   Shiny files (ui.R, server.R) plus R data saved.

   To launch the Shiny app, type the following two R commands:

        library(shiny)
        runApp("myapp")

   > # run the shiny app
   > library(shiny)
   Error in library(shiny) : there is no package called ‘shiny’
   Execution halted

Linux crash with focei-wang2007 test

While running testing with current main branch, I get the following error:

⠸ | 1     203 | focei-wang2007
malloc(): unsorted double linked list corrupted
Aborted (core dumped)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.