Skip to main content

Using R on Quest

Versions and Basic Use

You can see which versions of R are available on Quest, and which version is the default, with the command

module avail R

You can make a particular version of R available to use by typing

module load R/3.3.1

with the appropriate version number as listed in the output from module avail R. You need to load an R module even if you want to use the default version of R.

After you've loaded the R module, you can use the command R to start the command line version of R or rstudio to launch the graphical IDE. If you want to use RStudio, you need X-windows functionality enabled for your connection. See Logging in to Quest for instructions on connecting to Quest with support for the X Window System.

In submission scripts for batch jobs, you must include the command to load the version of R that you want to run, then you can call R using:

R CMD BATCH myprog.R myprog.log

which causes the file myprog.log to be written in the working directory.

Usage Notes

While module load R will load the current default version of R, to ensure the future compatibility of your scripts with the Quest system, we recommend that you always load a specific version of R rather than relying on the default version.

RStudio automatically creates and saves a .Rhistory file in your default working directory when you quit. If you do not change the working directory during your R session, then the default working directory is the directory from which you launched RStudio. RStudio also automatically loads any available .Rhistory file from the default working directory when it starts. .Rhistory files will be accessible to, and possibly shared by, anyone with access to the directory. You can prevent RStudio from automatically saving the history file by going to the Tools > Global Options menu in RStudio. The command line version of R only creates and saves an .Rhistory file when creating a .RData file.


R packages are installed, whether system-wide or locally in your own directory, for specific versions of R. If you switch versions of R, you may need to reinstall packages you use.

Package Installation

R packages can be installed from CRAN by launching RStudio and using the Packages tab in the bottom-right window, or by running R and using the install.packages command:

install.packages(c("packagename1", "packagename2"))

with a list of the packages you need. Packages should generally be installed under your home directory. They will be available for you to use across Quest nodes.

First-time Installation

The first time you install an R package on Quest, you may see an error like:

Warning in install.packages("glmnet", repos = "") :
  'lib = "/hpc/software/R/3.3.1/lib64/R/library"' is not writable
  Would you like to use a personal library instead? (y/n) 

Answer "y" to use a personal library.  Then it will ask you:

Would you like to create a personal library
  to install packages into? (y/n)

Answer "y" again.  The installation should then proceed successfully.  This will install the packages in your home directory.

Setting the Repository

If you get an error message indicating that a particular package isn't available for a certain version of R, or you get another error related to the package repository, you may need to explicitly set the mirror from which you want R to download the package. List of CRAN mirrors. Choose an http (instead of https) mirror. You can set the mirror before trying to install packages with the command:


or as part of the install.packages call with the repos argument:

install.packages(c("packagename1", "packagename2"), repos="")

More Options

See the R help page for install.packages for more options, such as installing local (user-created or downloaded) packages or changing the directory where packages are installed. The latter can be used to install packages in your project space instead of your home directory, which might be useful if others on the allocation also need to access the packages. To install packages from GitHub, use the install_github function in the devtools package or use the githubinstall package.

Task Views

CRAN Task Views are collections of packages used frequently in particular fields. They allow you to install all of the packages associated with the task view at once. See the R documentation for more details and the commands to use.

System-wide Packages

A limited number of R packages have been installed centrally for each version of R. These packages can be used without downloading and installing them first. You can get a list of the currently installed packages with the command:


If there is an R package that many users in your group need to use, and you'd like that package to be installed centrally, please contact

Last Updated: 26 July 2017

Get Help Back to top