Conda R

This tutorial guides you through creating and using your own Conda environment with R on Rockfish.

Connect to Rockfish (Login Node)

Open a terminal and run:

ssh YourUserID@login.rockfish.jhu.edu

Enter your Rockfish password when prompted.

Warning

Since computational tasks shouldn’t run on login nodes, you’ll next connect to a compute node.

Connect to a Compute Node

interact -p shared -n 6 -t 02:00:00

Parameter Guide

  • -p: Partition (express, shared, parallel)

  • -n: Number of cores - express: up to 4 cores - shared: up to 32 cores - parallel: up to 48 cores

  • -t: Job time in HH:MM:SS - express: up to 8 hours - shared: up to 36 hours - parallel: up to 72 hours

Load Anaconda Module

module reset
module load anaconda3/2024.02-1

Create the Conda Environment

conda create --name myR_env r-base=4.4.1 -y

Explanation

  • --name myR_env: Name of your environment

  • r-base=4.4.1: R version

  • -y: Auto-confirm prompts

Configure Conda Channels

conda config --env --add channels defaults
conda config --env --add channels bioconda
conda config --env --add channels conda-forge
conda config --env --set channel_priority strict

Activate the Environment

conda activate myR_env

Once activated, all R packages will be installed inside this environment.

Install R Packages

Example: Install devtools

Option 2: From within R

Start R:

R

Inside R:

install.packages("devtools")

Note

💡 If you encounter errors related to missing system libraries (e.g., libcurl, git, openssl), use the Conda method instead — it handles system dependencies automatically.

🔍 Not sure whether a package is available via Conda or CRAN? A quick Google search will usually help.

Deactivate the Environment

conda deactivate

To reactivate it later:

module load anaconda3/2024.02-1
conda activate myR_env

List all your environments:

conda env list

Exit the Compute Node

exit