R and Rstudio Server

R is a programming language and software environment for statistical computing and graphics.  
R offers a wide variety of statistics-related libraries and provides a favorable environment for statistical computing and design. In addition, the R programming language gets used by many quantitative analysts as a programming tool since it's useful for data importing and cleaning.

In order to see different versions of R installed on the cluster, run the command:

module avail R

You can obtain R in your environment by loading the R module i.e.:

module load R

The command R --version returns the version of R you have loaded:

R --version

In order to run the loaded R module you can enter this command to work with it and get the prompt:

R

To check available libraries and packages inside R, use the following command:

library(library-name)
OR
installed.packages()

For adding a new package that is missing you can install it using the command:

install.packages("package-name")

RStudio Server 
Rstudio server enables you to provide a browser-based interface to a version of R running on a remote Linux server, bringing the power and productivity of the RStudio IDE to server-based deployments of R.
Users can see the installed Rstudio versions by running the following commands:

module avail rstudio-server

The command output will list down all the installed versions of the module. Follow these instructions to load Rstudio:-

RStudio Server is not allowed on the head node; it must be run in an interactive Slurm
session. For example, you could run:

  srun --partition=high2 --time=9:00:00 --cpus-per-task=4 --mem=20G --pty /bin/bash -l

Adjust the --partition= argument to your high partition of choice, and adjust the --mem=
argument to be large enough to encompass your entire R session.

Once your session launches, reload this module again and follow these instructions:
module load R
rstudio-launch
You need to use SSH tunneling to allow your computer to communicate with
RStudio Server on the cluster.

Run the following command in a new terminal on your computer:

   ssh -L49159:cpu-6-66:49159 posmani@farm.hpc.ucdavis.edu

Then, on your computer, navigate your browser to:

   URL: http://localhost:49159
   Username: User1
   Password: ****