Description

R is a language and environment for statistical computing and graphics. R provides a wide variety of statistical and graphical techniques and is highly extensible. Example analysis that can be done with R include linear and nonlinear modeling, classical statistical tests, time-series analysis, classification, and clustering.

Availability

R is free software under the GNU project and is available for Windows, macOS, and Linux systems. To install R on your local system, visit the R Project website to download the installation files.

On the SCC there are multiple versions of R available as modules. A complete list of R versions available can be found on the R modules summary page. One can also view this list inside a terminal connected to the SCC by executing the following command:

scc1$ module spider R

Quick Start Guide to using R on the SCC

Below are two quick start guides for using R on the SCC and the third bullet point is a link to a video for a more detailed introduction to using R on the SCC.

Using OnDemand

  1. Log on to the SCC OnDemand Portal. (See our OnDemand page to learn more about this portal).
  2. Click on Interactive Apps and then on RStudio Server.
    An animated GIF showing the SCC OnDemand home webpage. The mouse moves to the top menu bar and click on "Interactive Apps". It then proceeds down the list of applications and clicks on "RStudio Server".
  3. In the drop down menus select the latest version of RStudio and a version of R you wish to load. Additionally, specify number of hours and cores for the job.
    NOTE: If you belong to more than one SCC project, select the appropriate project in the “Project” drop down menu at the bottom of the form.

    An animated GIF showing the OnDemand job request form for RStudio Server. The mouse moves to the "RStudio Version" drop down menu and selects versions "2024.04.2-764". The mouse then selects R version 4.4.0 for field "R Version. Finally, the mouse moves down to the form to and clicks on "Number of hours" and "Number of cores" text fields. The default values of 12 hours and 1 core is left as is.

  4. Click Launch to submit the job request. Once the job status changes from Queued to Running, click Connect to RStudio Server button to connect to the RStudio session.
    An animated GIF showing the SCC OnDemand job request for for RStudio Server. The form is already filled out, the mouse scrolls the page down to the bottom of the form and clicks on "Launch". The page changes to the "My Interactive Session" page where the RStudio Server job just submitted is shown to be in the "Queued" state. The job state changes to "Starting" and then "Running". The mouse then moves to the "Connect to RStudio Server" button and clicks it. The page then changes showing the RStudio Server page.
  5. After connecting to the RStudio session, set your working directory to the appropriate SCC project directory using setwd() function. Then set the “File” pane to the working directory by clicking the blue gear icon and click “Go to working directory”.
    An animated GIF showing the bottom half of the RStudio Server window, with the "console" tab showing on the left pane and the "Files" tab showing on the right pane. The mouse moves to the Console pane and click on the prompt. Then the command 'setwd("/projectnb/scv/milechin/r_code/")' is executed to set the working directory. The mouse then moves to the "Files" pane on the right and clicks on the blue gear icon and from the menu selects "Got to working directory" option. The "Files" pane updates and shows the contents of directory "/projectnb/scv/milechin/r_code/".
  6. Click on the “Packages” tab to see a list of R packages already installed and ready for your use. You can install your own R Packages if you need one that is not listed in the “Packages” tab.
    An animated GIF showing RStudio Server window. A mouse moves to the "packages" tab and clicks on it. The window shows a list of R packages already installed and ready for use in R.

Starting R Console within a Terminal

  1. Open a terminal connected to the SCC.
  2. Print the available versions of R by executing the following command:
    scc1$ module spider R
  3. Use the module load command to load the version of R desired and then run the R executable to start the R console within the terminal.
    scc1$ module load R/4.4.0
    scc1$ R
  4. To list all the R Packages already installed, run the following installed.packages() command:
    > installed.packages()[,c("Package", "Version")]
  5. To exit the R console, execute the quit function:
    > q()
NOTE: Log-in nodes (SCC1, SCC2, GEO, and SCC4) are not to be used for computation tasks, but for general purpose tasks. This may include editing files, managing files on the file server, installing R packages, or submitting jobs. Request an OnDemand Session if you plan to run computation tasks interactively.

Installing R Packages

Researchers are able to install their own R packages on the SCC. By default, these packages will be installed in the Home directory (~/R/x86_64-pc-linux-gnu-library/4.X). When installing a package for the first time, you maybe prompted with questions about creating this directory in your Home directory. The first question will ask if you want to use a “personal library”, as an example shows below.

> install.packages("tidycensus") 
Installing package into ‘/usr1/project/username/R/x86_64-pc-linux-gnu-library/4.4’ (as ‘lib’ is unspecified) 
Warning in install.packages : 'lib = "/usr1/project/username/R/x86_64-pc-linux-gnu-library/4.4"' is not writable 
Would you like to use a personal library instead? (yes/No/cancel)

Type in yes and hit Enter key.

The second question will ask you to confirm the location of the personal library and propose a default location in your home directory:


Would you like to create a personal library
‘/usr1/scv/milechin/R/x86_64-pc-linux-gnu-library/4.4’
to install packages into? (yes/No/cancel) 

Type in yes and hit Enter key to accept the default location.

After the directory is created, the installation should proceed as normal. If you have an issue installing an R package, please fill out the Software Request Form to get assistance from our team.

Additional Help/Documentation

Internal Resources