R Conda Environments and Installed Packages
Goal: Understand R environments build with Conda.
Note: There is a known vulnerability with R versions less than 4.4.0.
This page uses R version 4.3.3. This page is purely for example since as of the date of creating this page there were issues using an r-base/4.4.1.
I am hoping in a few weeks/months the 4.4.x base will be stable and I’ll update the examples.
- 1 Basic R Conda Environment
- 2 Where are Packages Installed?
- 3 Try Installing vctrs Package
- 4 Where was this installed?
- 5 But What about the R_LIBS_USER Environment Variable?
- 6 Can I Create this Folder?
- 7 Should I Create this Folder?
- 8 Try Installing stringi Package
- 9 Conda Install stringi Package: Search
- 10 Conda Install stringi Package
- 11 Where was this installed?
- 12 Anaconda: R Essentials
Basic R Conda Environment
General Process:
[]$ cd /project/<project-name>/software/conda-envs/
[]$ module purge
[]$ module load miniconda3/24.3.0
[]$ conda search r-base
Loading channels: done
# Name Version Build Channel
...
r-base 4.3.3 hf0d99cb_1 conda-forge
...
r-base 4.4.1 h1dca405_0 conda-forge
[]$ conda create -p r_4.3.3_env r-base=4.3.3
[]$ conda activate /cluster/medbow/project/<project-name>/software/conda-envs/r_4.3.3_env
(/cluster/medbow/project/<project-name>/software/conda-envs/r_4.3.3_env) []$ R --version
R version 4.3.3 (2024-02-29) -- "Angel Food Cake"
...
Where are Packages Installed?
(/cluster/medbow/project/<project-name>/software/conda-envs/r_4.3.3_env) []$ R -e 'Sys.getenv(c("R_PLATFORM", "R_HOME", "R_LIBS_USER", "R_LIBS", "R_LIBS_SITE"))'
R version 4.3.3 (2024-02-29) -- "Angel Food Cake"
...
> Sys.getenv(c("R_PLATFORM", "R_HOME", "R_LIBS_USER"))
R_PLATFORM "x86_64-conda-linux-gnu"
R_HOME "/cluster/medbow/project/<project-name>/software/conda-envs/r_4.3.3_env/lib/R"
R_LIBS_USER "/cluster/medbow/home/<username>/R/x86_64-conda-linux-gnu-library/4.3"
R_LIBS ""
R_LIBS_SITE "/cluster/medbow/project/<project-name>/software/conda-envs/r_4.3.3_env/lib/R/site-library"
Try Installing vctrs
Package
# Within R:
> install.packages("vctrs")
...
also installing the dependencies ‘cli’, ‘glue’, ‘lifecycle’, ‘rlang’
...
* DONE (vctrs)
Where was this installed?
But What about the R_LIBS_USER
Environment Variable?
Can I Create this Folder?
Example of sharing R Packages across multiple Conda Environments.
Should I Create this Folder?
Try Installing stringi
Package
Conda Install stringi
Package: Search
Conda Install stringi
Package
Where was this installed?
Anaconda: R Essentials
Although we do not recommend installing Anaconda (unless you are comfortable with how it works and modifies your home environment), it does provide an R Essentials bundle which “includes approximately 80 of the most popular scientific packages for the R programming language.“