Platform R: Quickstart for the R Programming Language
There are two main ways to get quickly started using R on Platform R: using conda, or using a container. Spack is also an option, but the Platform R team has scheduled Spack for a major version upgrade (Summer 2026), which will change some things.
Installing R with Conda
Conda-Forge supports R along with many common R libraries. In general, it will be cleaner if you install R packages using conda if you have decided to use Conda to install your R. Packages which require C, C++, or Fortran to build are often easier to manage with Conda or in a container if they require specialized operating system libraries.
You can visit the Conda-Forge packages page to search for R packages. They all start with "r-".
When you use Conda to install R, any packages you install with install.packages() go into your Conda environment version of R, not into your home directory. However, it is safest to use Conda to install additional libraries whenever possible.
Example Installation
To create a new Conda environment for R, along with the MASS, tidyverse, and hdf5r libraries:
conda create --name my-r-demo r-base r-mass r-tidyverse r-hdf5r
Run conda activate my-r-demo and then start R.
With the environment active, you can install additional packages, such as: conda install r-survival
You can delete this test my-r-demo environment with the command: conda remove -n my-r-demo --all
Example Slurm Batch File
Note that the Rscript is used instead of R for batch scripts. The --vanilla option prevents loading previous R session data.
#!/bin/bash
#SBATCH --partition=cpu
#SBATCH --job-name="r-with-conda"
#SBATCH --time=30:00
#SBATCH --mem=32G
#SBATCH --cpus-per-task=1
#SBATCH --error=out/job.err
#SBATCH --output=out/job.out
conda deactivate
conda activate my-r-demo
srun Rscript --vanilla my_code.RUsing a Platform R Container
The Platform R team provides ready-built containers for a few software packages. The R container has additional operating system libraries commonly used by bioscience R packages, to make it easier to install R packages you need directly.
With this container, packages installed with install.packages() go into your Platform R home directory.
You can start an interactive R session with:
srun \
--singularity-container=/mnt/scratch/shared/containers/platformr-r-4.5.2.sif \
--mem=32G --pty R
Example Slurm Batch File
Note that the Rscript is used instead of R for batch scripts. The --vanilla option prevents loading previous R session data.
#!/bin/bash
#SBATCH --partition=cpu
#SBATCH --job-name="r-with-conda"
#SBATCH --time=30:00
#SBATCH --mem=32G
#SBATCH --cpus-per-task=1
#SBATCH --error=out/job.err
#SBATCH --output=out/job.out
conda deactivate
conda activate my-r-demo
srun --singularity-container=/mnt/scratch/shared/containers/platformr-r-4.5.2.sif \
--pty Rscript --vanilla my_code.RThe backslash in the srun line splits the command across multiple lines for readability. Everything could be on the same line.
