Chapter 4 Installation

You can install the released version of rxode2 from CRAN with:

install.packages("rxode2")

The fastest way to install the development version of rxode2 is to use the r-universe service. This service compiles binaries of the development version for MacOS and for Windows so you don’t have to wait for package compilation:

install.packages(c("dparser", "rxode2ll", "rxode2parse",
                   "rxode2random", "rxode2et", "rxode2"),
                 repos=c(nlmixr2="https://nlmixr2.r-universe.dev",
                         CRAN="https://cloud.r-project.org"))

If this doesn’t work you install the development version of rxode2 with

devtools::install_github("nlmixr2/rxode2parse")
devtools::install_github("nlmixr2/rxode2random")
devtools::install_github("nlmixr2/rxode2et")
devtools::install_github("nlmixr2/rxode2ll")
devtools::install_github("nlmixr2/rxode2")

To build models with rxode2, you need a working c compiler. To use parallel threaded solving in rxode2, this c compiler needs to support open-mp.

You can check to see if R has working c compiler you can check with:

## install.packages("pkgbuild")
pkgbuild::has_build_tools(debug = TRUE)

If you do not have the toolchain, you can set it up as described by the platform information below:

4.0.1 Windows

In windows you may simply use installr to install rtools:

install.packages("installr")
library(installr)
install.rtools()

Alternatively you can download and install rtools directly.

4.0.2 Mac OSX

To get the most speed you need OpenMP enabled and compile rxode2 with that compiler. There are various options and the most up to date discussion about this is likely the data.table installation FAQ for MacOS. The last thing to keep in mind is that rxode2 uses the code very similar to the original lsoda which requires the gfortran compiler to be setup as well as the OpenMP compilers.

If you are going to be using rxode2 and nlmixr together and have an older mac computer, I would suggest trying the following:

library(symengine)

If this crashes your R session then the binary does not work with your Mac machine. To be able to run nlmixr, you will need to compile this package manually. I will proceed assuming you have homebrew installed on your system.

On your system terminal you will need to install the dependencies to compile symengine:

brew install cmake gmp mpfr libmpc

After installing the dependencies, you need to re-install symengine:

install.packages("symengine", type="source")
library(symengine)

4.0.3 Linux

To install on linux make sure you install gcc (with openmp support) and gfortran using your distribution’s package manager.

4.0.4 R versions 4.0 and 4.1

For installation on R versions 4.0.x and 4.1.x, please see the instructions on how to install symengine in the nlmixr2 installation instructions: https://github.com/nlmixr2/nlmixr2#r-package-installation

4.1 Development version

Since the development version of rxode2 uses StanHeaders, you will need to make sure your compiler is setup to support C++14, as described in the rstan setup page. For R 4.0, I do not believe this requires modifying the windows toolchain any longer (so it is much easier to setup).

Once the C++ toolchain is setup appropriately, you can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("nlmixr2/rxode2parse")
devtools::install_github("nlmixr2/rxode2random")
devtools::install_github("nlmixr2/rxode2et")
devtools::install_github("nlmixr2/rxode2ll")
devtools::install_github("nlmixr2/rxode2")