Installing R Packages on RStudio OnDemand.

When to Use?

When using RStudio on the OnDemand interface, direct installation of packages may not be permitted. To install an R package, you will need to use the command line by SSHing into the HPC cluster. The following steps guide you through the process:

Procedure

Step 1: SSH into the HPC Cluster

Open a terminal on your local machine and connect to the HPC cluster. Avoid using the terminal within the OnDemand site. Use the following command, replacing username and hpc-cluster-address with your credentials and the cluster's address:

ssh username@clipper.gvsu.edu

Step 2: Load the R Module

Once logged in, load the R module by typing:

module load r

R Module screen with typed command, "module load r"

Step 3: Launch R

After loading the module, enter R by typing:

R

Step 4: Install the Desired Package

Within the R environment, install the required package using the install.packages() function. For example, to install the hierfstat package: 

install.packages("hierfstat")

R Module screen with typed command, 'install.packages("hierfstat")'

Step 5: Choose a CRAN Mirror

After running the command, you will see a list of CRAN mirrors. Select a mirror close to your location by typing the corresponding number. For example, if "USA MI" is listed as option 66, type:

66

R Module screen displaying a list of CRAN mirrors

Step 6: Exit R

Once the installation is complete, exit the R environment by typing:

q()

Step 7: Refresh the OnDemand Interface

Go back to the OnDemand site and refresh the interface. Navigate to the "User Library" section. The installed package should now appear in the list of available libraries. Select it to include it in your R script.

OnDemand site User Library screen

Troubleshooting Tips

  • Ensure the R module is loaded before attempting to install a package.

  • If the package does not appear in the "User Library" after installation, verify that the installation was successful by repeating Steps 1-5.

  • For permission issues or other errors, contact the system administrator or HPC support team.

Was this helpful?
0 reviews