This repository serves as a demonstration of using the {rix} package to manage R package dependencies while leveraging the Nix package manager. The R scripts in this repository originate from the Pharmaverse examples repository, and were also featured in the Package Management session examples:
- Creation of the SDTM demographic (
DM) domain: https://pharmaverse.github.io/examples/sdtm/dm.html - Creation of the ADaM analysis dataset (
ADSL) domain: https://pharmaverse.github.io/examples/adam/adsl.html - Creation of a Demographic summary table: https://pharmaverse.github.io/examples/tlg/demographic.html
- Install the Nix package manager following the appropriate vignette from the
{rix}documentation site:
- Start a new R session with the
{rix}package available. Notice that we did not include R as a prerequisite. That is not an accidental ommission, as you can obtain a custom R environment directly with the Nix package manager by running the following command:
nix-shell -p R rPackages.rixAfter the dependencies are installed, you will be in a new environment with R and the rix package available.
- Run the following command to create the Nix configuration file for this project:
Rscript build_config.RYou could also launch R itself in the shell and simply run source("build_config.R") if you wish. The result of this command will be the creation of default.nix, the configuration file used by Nix to create the project environment.
- Exit out of this particular Nix session by typing
exitin the terminal. You should be returned to your default computer environment. - Initialize the project environment and immediately enter a custom shell by running the following command:
nix-shellOnce the dependencies are installed, you will now be in a new Nix shell environment.
- Launch R either through the terminal or through an IDE such as Positron to run the scripts in this repository.