This guide presents an overview of managing personal R installations
Table of Contents
Creating virtual environment with conda
Installing R packages with conda
Installing R packages with BiocManager
Creating virtual environment with conda
Conda is an environment and package manager that allows you to create virtual environments and install a variety of packages from the Anaconda open-source repository to include R.
To use conda, first load one of the available Anaconda modulefiles from within a command-line session on Longleaf or Sycamore. When loading the Anaconda modulefile, please ensure that there aren't other Python modulefiles loaded at the same time as this can create conflicts. The general syntax for creating a conda environment with a specific version of R and activating that environment is as follows:
$ module purge
$ module load anaconda
$ conda create --prefix=/users/<o>/<n>/<onyen>/<env_name> r-base=4.2.1 r-essentials zlib libpng freetype cairo pango jpeg libtiff xz bzip2 openblas
If you do not already have conda-forge and bioconda listed in your current channels (conda config --show channels), run the following prior to conda create:
conda config --add channels conda-forge
conda config --add channels bioconda
In the above example, an environment using R 4.2.1 is created in the directory specified via the --prefix option. This path must be passed as an argument to the conda activate command:
$ conda activate /users/<o>/<n>/<onyen>/<env_name>
Installing R packages with conda
After activating the conda environment, you can install packages from several online channels, which will be available to you each time you activate your conda environment. Using the r-gplots package as an example, you can use the following syntax to install packages from the Anaconda open-source repository:
(<env_name>) conda install -c anaconda r-gplots
Installing R packages with R
If you find the latest available version of your required package is not available in from the Anaconda open-source repository, you can install directly with R. Using flextable package as an example:
(<env_name>) $ R
> install.packages("flextable")
Installing R packages with BiocManager
If you are working in bioinformatics/genomics/systems biology, BiocManager might be the right package manager. To install BiocManager:
(<env_name>) $ R
> install.packages("BiocManager")
To install a package with BiocManager:
(<env_name>) $ R
> BiocManager::install("pals")
Open Ondemand/RStudio Usage
Start a "Longleaf Desktop" session. Open the terminal console once the session starts and run the following:
$ module load r rstudio anaconda
$ conda activate /users/<o>/<n>/<onyen>/<env_name>
(<env_name>) $ export LD_LIBRARY_PATH=/users/<o>/<n>/<onyen>/<env_name>/lib/R/lib
(<env_name>) $ rstudio
Last Update 10/27/2025 4:41:41 PM