Following the possibility to have different R/DataSHIELD server profiles (see :ref:`cb-r` and :ref:`cb-datashield-profiles`), it may be necessary to have different R environment on the client side as well. This is mandatory in the case of DataSHIELD where a server-side package only works with a specific client-side package version.
This concept of R environment is covered by the renv R package which intends to provide isolated, portable and reproducible R projects. Using renv
gives full control of the user on its R exection environment, without depending on an IT infrastructure (different interfaces for different profiles).
In order to help with setting up such project, you can start with the DSProjectTemplate.
As an example some of the DataSHIELD R packages are not available in the official CRAN repository. For R packages saved on GitHub you can use the following procedure to include a new dependency:
Note
- Run
renv::install()
to retrieve a specific version of a R package from GitHub; for examplerenv::install("neelsoumya/dsSurvivalClient@v1.0.0")
to install a released version of dsSurvivalClient - Edit your analysis script to make use of this package; for example
library(dsSurvivalClient)
- Run
renv::snapshot()
to register this package as part of your project environment
This is as simple as:
Note
- Edit your analysis script and remove the
library()
load statement of the package - Run
renv::snapshot()
to unregister this package from your project environment