One of the easiest way to setup nlmixr is to docker image. For more details see:
For those not interested in customized installation on Windows, we recommend you download a Windows installer for your platform from the following link: https://github.com/nlmixrdevelopment/nlmixr/releases/
STOP AT THIS POINT IF YOU USED THE INSTALLER
Sometimes trying to install yourself will corrupt the installation and nlmixr will not run.
To replicate the environment that was used in Windows for nlmixr
development, you will need administrator rights, and you should perform the following steps:
C:\R\R-3.5.0
, but you can also use the default location (C:\Program Files\R\R-3.5.0
) as well, if really needed.c:\Rtools
RxODE
, a required component of nlmixr
, checks and sets up the path based on the following:
a. Rtools
is in the path (fastest and recommended option)
b. Rtools
was installed with information saved to the Windows registry, and RxODE
can find the installation.
c. Rtools
is on a hard drive installed in either Rtools
or RBuildTools
PATH
environment variable, or RxODE
and nlmixr
will not work (this should be done automatically during installation).nlmixr
. When installing, use the Python 3.6 version. During the installation, Anaconda provides the option of adding itself to the PATH
environment variable, but advises against it; please do this anyway (despite the red warning).pip
.PATH
environment variable, or RxODE
and nlmixr
will not work, no matter what Anaconda might say.devtools
.
install.packages("devtools")
.devtools
using library(devtools)
.RxODE
.
RxODE
is in the process of being uploaded to CRAN. nlmixr
needs this newer version of RxODE
to function correctly. To install this version, use the command: install_github("nlmixrdevelopment/RxODE")
.RxODE::rxWinPythonSetup()
to install the required package SnakeCharmR
and to make sure Python and SymPy are working properly. Since SnakeCharmR
is orphaned, it may not work without installing directly from github with the following command: devtools::install_github("nlmixrdevelopment/SnakeCharmR")
library(SnakeCharmR)
.RxODE
completely, you can type the following library(RxODE); rxTest();
and it will run all of the unit tests in RxODE to make sure it is running correctly on your system. (Note that the testthat
package is required for this, and it will take a long time.). This also requires installing RxODE
with the tests. Devtools changed so that tests are no longer installed by default. The correct command to install the test suite is:devtools::install_github("nlmixrdevelopment/RxODE", INSTALL_opts="--install-tests")
nlmixr
.
devtools
again using library(devtools)
nlmixr
shares some stan headers, nlmixr now needs C++14
support. To ease the setup you can run the command RxODE::rxC14()
which creates the following build file in ~/.R/Makevars.win
. If there are problems you may have to edit the file manually to match your configuration.# Makvars.win
CXX14=$(BINPREF)g++ $(M_ARCH)
CXX14STD=-std=c++1y
CXX14FLAGS=-O2 -Wall
nlmixr
by running devtools::install_github("nlmixrdevelopment/nlmixr")
Instructions for Ubuntu-alike distributions are given here (specifically, Ubuntu 16.04 Xenial Xerus), but all current Linux distributions are supported, in principle.
sudo
). Provide your admin password when asked.sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo add-apt-repository 'deb [arch=amd64,i386] https://cran.rstudio.com/bin/linux/ubuntu xenial/'
. If you aren’t using Ubuntu Xenial, change xenial
to match your distribution’s codename.sudo apt-get update
.sudo apt-get install r-base r-base-dev libssl-dev
sudo apt-get install python-sympy python-pip python-setuptools python3-pip python-dev python3-dev
.devtools
and dependencies.
sudo apt-get install build-essential
devtools
from a clean R session by entering install.packages("devtools")
.devtools
using library(devtools)
.RxODE
.
RxODE
is in the process of being uploaded to CRAN. nlmixr
needs this newer version of RxODE
to function correctly. To install this version, use the command: install_github("nlmixrdevelopment/RxODE")
.SnakeCharmR
using install_github("nlmixrdevelopment/SnakeCharmR")
.library(SnakeCharmR)
.RxODE
completely, you can type the following library(RxODE); rxTest();
and it will run all of the unit tests in RxODE to make sure it is running correctly on your system. (Note that the testthat
package is required for this, and it will take a long time.)
remotes::install_github("nlmixrdevelopment/RxODE", INSTALL_opts="--install-tests")
nlmixr
.
install_github("nlmixrdevelopment/nlmixr")
Instructions for macOS 10.13 Mojave are provided here. They should be broadly extensible to all recent releases of macOS, however.
R-3.6.1.pkg
(or later) from CRAN.pip
from the macOS terminal prompt: sudo easy_install pip
.
easy_install
doesn’t work, you can download by curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
and then run sudo python get-pip.py
sympy
using pip
: sudo -H pip install sympy
.xcode-select --install
and then choose install
. This allows you to compile the package without downloading the entire (large) Xcode package. Make sure to perform this step even if the Xcode package is already installed.sudo installer -pkg \
/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg \
-target /
~/.Rprofile
to have the following line to adjust the paths in R to use the CRAN compilers (if not present, create the .Rprofile file):
# make sure to adjust the version number of clang based on the downloaded version in step 3 (e.g. clang8/bin)
Sys.setenv("PATH"=paste0("/usr/local/clang8/bin:/usr/local/gfortran/bin:", Sys.getenv("PATH")))
Make Sure you have an extra line at the end of this file; Otherwise R will not pick up the correct paths.
You also need to create a directory ~/.R
and then put a file Makevars
in it; The context of the file should contain:
devtools
and dependencies.
devtools
from a clean R session by entering install.packages("devtools")
.devtools
using library(devtools)
.RxODE
.
RxODE
is in the process of being uploaded to CRAN. nlmixr
needs this newer version of RxODE
to function correctly. To install this version, use the command: install_github("nlmixrdevelopment/RxODE")
.reticulate
using install.packages("reticulate")
.RxODE
completely, you can type the following library(RxODE); rxTest();
and it will run all of the unit tests in RxODE to make sure it is running correctly on your system. (Note that the testthat
package is required for this, and it will take a long time.)
remotes::install_github("nlmixrdevelopment/RxODE", INSTALL_opts="--install-tests")
nlmixr
.
install_github("nlmixrdevelopment/nlmixr")
If you have multiple versions of python installed on your system, you may run into some more issues. To be more careful in your install, you can install SnakeCharmR as follows:
Sys.setenv(SNAKECHARMR_PYTHON_VERSION="/path/to/python/with/sympy/installed")
devtools::install_github("nlmixrdevelopment/SnakeCharmR")
You may also have to adjust the following python variables to match the version with sympy installed:
Environmental Variable | Correct value |
---|---|
PYTHON_EXE |
Path where the python with sympy is installed |
PYTHONHOME |
Path where the python with sympy is installed |
PYTHON_INCLUDE |
Path where the python libraries are installed; In windows this is PYTHONHOME\include
|
PYTHON_LIB |
Path where python libraries are installed; In windows this is PYTHONHOME\libs
|
PYTHONPATH |
Path where python searches. In windows this is a path-style variable including PYTHONHOME\DLLs , PYTHONHOME\Lib and PYTHONHOME\Lib\site-packages . |
PYTHONSTARTUP |
In windows, this value is unset if present |
I believe you could also unset some of these variables and python can figure them out. Please be warned if these variables are not setup correctly a call to python will abort python. The python abort does not respect R’s way of doing things and will also abort/crash R.
To test without running a model you may wish to try
library(SnakeCharmR)
If it doesn’t crash R, then python is likely setup correctly.
After that point you can then type:
It will show the version of sympy that you are using if SnakeCharmR is setup correctly.
Once nlmixr is installed, you can test if everything is working well (as well as running shinyMixR) by running this install checker by Richard Hooijmaijers & Matt Fidler.
Once downloaded you would source the code; If successful you should see something similar to the following:
> source("test_install.R")
Correct R version: Yes, R version 3.5.0 (2018-04-23)
RxODE installed: Yes
Python installed: Yes, Python 3.6.2
sympy installed: Yes
devtools package installed: Yes
Rtools installed: Yes
RxODE package installed: Yes
SnakeCharmR package installed: Yes
nlmixr package installed: Yes
xpose.nlmixr package installed: Yes
shinyMixR package installed: Yes
Loading required package: nlme
nlmixr run under nlme: Yes
nlmixr run under saem: Yes
---- Installation test finished! ----