The R console and Mini-apps come with a number of the most commonly used data science packages pre-installed (e.g. ggplot2, dplyr, RPostgreSQL, etc). To get the best performance you should only ever install these specific packages manually if they explicitly require a different version to the one that is baked in. To see the full list of pre-installed packages, please visit this article.
The built-in R console allows users to easily install packages from the CRAN repository. The list of packages available for installation is updated on a weekly basis. It is also possible to install packages not available in CRAN though the process is a bit more complicated as the package first must be downloaded to the user machine and then uploaded to the workspace manually.
General installation guidelines
The R packages installed from the R console or a Mini-app will be installed to a persistent location within the workspace. Therefore, you only need to install a package once, as all the other scripts and Mini-apps that use the same version of R will be able to access it.
The packages installed by workspace users can be found in
files/R/<R_version> and this location is included in the
libPaths of the R console, so users can load them using the following command:
To list all the installed packages from within the R console run:
To check whether a particular package is installed:
Installing R packages from CRAN
To install a package from a CRAN repository:
Since CRAN is a network of servers, known as mirrors, you can specify which mirror you would like to install the package from. Before selecting a mirror, check that it is whitelisted in your workspace.
To install a package from a specific CRAN mirror:
In order to avoid lengthy, unnecessary installations we recommend that
install.packages() should not be directly run within scripts unless the package is not already installed. This can either be done by setting up the desired library of R packages beforehand or by including code to only install the package if required. The following command will only install a package if it cannot already be loaded:
More detailed information on package installation are available from the R manuals at CRAN.
Installing R packages not hosted on CRAN
Because Internet access in the workspace is restricted, you will need to download the package that you want to install to your local machine first, and then upload it to the workspace. Make sure that dependencies are available on CRAN or you will have to upload them manually as well.
In this example, we will show you how to install ggman package used for creating Manhattan plots.
First, navigate to ggman GitHub repository, and download the package as a ZIP file.
Then, upload the ZIP file to the workspace folder of the R version in which you intend to install the package. In this example, we upload the ZIP file to
Next, open the R console, and install the
Then, load the
Install the package:
Test the installation:
Package installation issues
In some circumstances, packages may fail to install. There are several possible reasons for this:
- The necessary system requirements are not available.
- The package is incompatible with the version of R running in the console. If you require access to a specific package that fails to install please contact the Service Desk.