Rstudio Sessions and Environment Management
Research Computing hosts robust documentation and guidance on using both R and RStudio on HPC research clusters.
This supplement assumes Initial Setup is complete according to the Use Conda on Any PU HPC System guide. See the guide for additional environment management steps, such as removal.
Create a New R Environment
Perform these steps interactively in a shell on one of the cluster head nodes.
-
Use the conda command to create a new environment. For this example, we will name the environment
renv
, indicate we want to install R, and use the conda-forge channel as the source.conda create -n renv r-base -c conda-forge -y
- Activate the environment you just created. If you’ve done so successfully, the active environment name will be displayed before your prompt.
conda activate renv
-
Use the
conda
command to install additional R packages, if possible. Most, but not all, R packages are available viaconda
. The package name is always prefixed byr-
and in lowercase.conda install r-igraph -c conda-forge -y
-
If a package is unavailable via or unknown to
conda
, typeR
to enter an R prompt and use theinstall packages()
function. Exit the R prompt withq()
.> install.packages('gravity')
This installation method often requires the compilation of dependent libraries, making it a lengthy and error-prone process. Whenever possible, try to install the package via
conda
before pursuing this method.
Rstudio Session and the Environment
RStudio sessions on the clusters are interactive, scheduled under Interactive Apps with RStudio listed as “RStudio Server”.
When requesting an RStudio session, add the location of your environment’s R
command to the Add to Path field.
Retrieve this location by opening a Terminal, activating the environment, and typing which R
. Copy and paste the resulting value to the Add to Path field, removing the trailing R.