Skip to content

R

Description

R is a free software environment for statistical computing and graphics. Homepage: http://www.r-project.org/

Access

R is open to all HPRC users.

Loading the Module

To see all versions of R available:

[NetID@cluster ~]$module spider R

To load a particular version of R (Example: 4.3.2):

[NetID@cluster ~]$module load GCC/12.3.0 R/4.3.2

R_tamu

Loading the R module will setup the environment for the base R installation without any additional packages. For the user's convenience, HPRC developed an extension to R called R_tamu which is built on top of R and provides a large number of additionally installed packages not found in the base R version. R_tamu also makes it easy to install personal packages. In addition, R_tamu can also act as an R-project environment manager.

To see all versions of the R_tamu available:

[NetID@cluster ~]$module spider R_tamu

For more information about R_tamu, please visit the R_tamu page page

Installing Packages

While there are many packages available with the R_tamu module, you may find that we do not have a package installed that is needed. If you think that a particular package might be useful for other R users, you can contact us with a request to install this packages systemwide. Alternatively, you can install any packages yourself in your own directory.

The most common way to install a package is to start an interactive R session and use the R function

>install.packages("package_name")

Alternatively, you can also use R CMD INSTALL command from the shell. This is useful when you already have a local copy of the R package ( *.tar.gz format).

R_tamu sets the R environment variable R_LIBS_USER to ${SCRATCH}/R_LIBS/ ( where is currently loaded R version), so all packages will be automatically installed in that directory.

In case you are using the R module, you will be asked to provide a personal directory where to install it. The easiest way is to set R_LIBS_USER before you start your R session. For example:

[NetID@cluster ~]$ export R_LIBS_USER=${SCRATCH}/myRlibs

NOTE: In case you are using the R module, to be able to use the installed packages, R_LIBS_USER needs to be set every time before starting an R Session.

If you have trouble installing packages for yourself, you can also contact us with any concerns.

Usage on the Login Nodes

Please limit interactive processing to short, non-intensive usage. Use non-interactive batch jobs for resource-intensive and/or multiple-core processing. Users are requested to be responsible and courteous to other users when using software on the login nodes.

The most important processing limits here are: * ONE HOUR of PROCESSING TIME per login session.

  • EIGHT CORES per login session on the same node or (cumulatively) across all login nodes.

Anyone found violating the processing limits will have their processes killed without warning. Repeated violation of these limits will result in account suspension. Note: Your login session will disconnect after one hour of inactivity.

Using Drona Composer to run R jobs

Drona Composer provides a 100% graphical interface to create and submit R jobs without the need to write a Slurm script or even be aware of Slurm syntax. It guides you in providing the relevant information to generate and submit your R job.

Accesing Drona Composer

Drona is available on all HPRC Portals. Once you log in to the portal of your choice, select Drona Composer from the Jobs tab. This will open a new window showing the Drona composer interface.

Drona Environments

You can find the R environment in the Dropdown. The image below shows a screenshot of the Drona composer interface with a dropdown menu with all available environments. NOTE: if you don't see the R environment, you need to import it first. You only need to do this once. See the import section for more information.

Here, you will select the R environment. Once you select the R environment, the form will expand with several additional fields to guide you in providing all the relevant information. The screenshot below shows the extra fields.

Hover over the little question mark to get additional information for any of the input fields. It will show further information and help.

Once you have filled in all the fields, click the "preview" button. This will show the fully editable preview screen with the generated job script based on the provided input. You are welcome to inspect the generated files and make edits.

To submit the job, click on the submit button, and Drona Composer will submit the generated job on your behalf.

For detailed information about Drona composer, checkout the Drona Composer Guide

Usage on the Compute Nodes

Non-interactive batch jobs on the compute nodes allows for resource-demanding processing. Non-interactive jobs have higher limits on the number of cores, amount of memory, and runtime length.

For instructions on how to create and submit a batch job, please see the appropriate knowledgebase page for each respective cluster:

'

Slurm Example (grace)

Example 1: A serial (single core) R Job example

#!/bin/bash

##NECESSARY JOB SPECIFICATIONS
#SBATCH --job-name=R_Job        # Sets the job name to R_Job
#SBATCH --time=5:00:00          # Sets the runtime limit to 5 hr
#SBATCH --ntasks=1              # Requests 1 core
#SBATCH --ntasks-per-node=1     # Requests 1 core per node (1 node)
#SBATCH --mem=5G                # Requests 5GB of memory per node
#SBATCH --output=stdout1.o%J    # Sends stdout and stderr to stdout1.o[jobID]

## Load the necessary modules
module purge
module load foss/2022b
module load R_tamu/R_tamu/4.3.1

## Launch R with proper parameters
Rscript myScript.R

Example 2: A parallel R Job example (that starts an MPICluster, e.g. when using doMPI package), where myScript.R is a script that requests 10 workers. Note: The number of cores requested should match the number of workers requested + 1.

#!/bin/bash

##NECESSARY JOB SPECIFICATIONS
#SBATCH --job-name=R_Job        # Sets the job name to R_Job
#SBATCH --time=5:00:00          # Sets the runtime limit to 5 hr
#SBATCH --ntasks=10             # Requests 10 cores
#SBATCH --ntasks-per-node=10    # Requests 10 cores per node (1 node)
#SBATCH --mem=50G               # Requests 50GB of memory per node
#SBATCH --output=stdout1.o%J    # Sends stdout and stderr to stdout1.o[jobID]

## Load the necessary modules
module purge
module load foss/2022b
module load R_tamu/4.3.1


## Launch R with proper parameters
mpirun -np 1 Rscript myScript.R

To submit the batch job, run: (where jobscript is a file that looks like one of the above examples)

[ NetID@grace1 ~]$sbatchjobscript