Select Page

R-package installation and initialization

In this page, we present the installation procedure of the R-package that allow to run Simulx from R.

Installation

The R package lixoftConnectors is located in the installation directory as tar.gz ball. It can be installed directly using Rstudio (Tools > Install packages > from package archive file) or with the following R command:

install.packages(packagePath, repos = NULL, type="source", INSTALL_opts ="--no-multiarch")

with the packagePath = ‘<installDirectory>/connectors/lixoftConnectors.tar.gz’ where <installDirectory> is the MonolixSuite installation directory.

With the default installation directory, the command is:

# for Windows OS
install.packages("C:/ProgramData/Lixoft/MonolixSuite2020R1/connectors/lixoftConnectors.tar.gz",
repos = NULL, type="source", INSTALL_opts ="--no-multiarch")
# for Mac OS
install.packages("/Applications/MonolixSuite2020R1.app/Contents/Resources/\
monolixSuite/connectors/lixoftConnectors.tar.gz",
repos = NULL, type="source", INSTALL_opts ="--no-multiarch")

The lixoftConnectors package depends on the RJSONIO package that may need to be installed from CRAN first using:

install.packages('RJSONIO')



Initializing

When starting a new R session, you need to load the library and initialize the connectors with the following commands

library(lixoftConnectors)
initializeLixoftConnectors(software = "simulx")


In some cases, it may be necessary to specify the path to the installation directory of the Lixoft suite. If no path is given, the one written in the <user home>/lixoft/lixoft.ini file is used (usually “C:/ProgramData/Lixoft/MonolixSuite2020R1” for Windows). where XXXX corresponds to the version of MonolixSuite

library(lixoftConnectors)
initializeLixoftConnectors(software = "simulx", path = "/path/to/MonolixSuite/")

Making sure the installation is ok

To test if the installation is ok, you can load and run a project from the demos as on the following:

# load and initialize the API
library(lixoftConnectors)
initializeLixoftConnectors(software=”simulx”)

# Get the project
project <- paste0(demoPath, “2.models/longitudinal.smlx”)

# Run the simulation
runSimulation()

# The results are accessible through the function getSimulationResults()
# The results for the output is the list res and TS is one of the outputs

head(getSimulationResults()$res$TS)
id time TS
1 1 0 10.00000
2 1 1 11.04939
3 1 2 12.20862
4 1 3 13.48915
5 1 4 14.90359
6 1 5 16.46585