Using RStudio Package Manager with RStudio or R - Analytics Enclave

Overview:

This document outlines the basic steps for using RStudio Package Manager (RSPM) in Enclave Platform to configure repositories and access packages.

Prerequisites:
  1. Access to Enclave should already be granted and your workspace provisioned. If you do not have approval to access the Enclave Platform, complete and submit the Access Request Form.
  2. You should be logged on to your Enclave Windows VDI. You cannot access the Enclave environment and resources therein from outside the platform.

Step-by-Step Instructions:

Step 1 Connecting to RSPM repositories. 

Using the available browsers (Google Chrome or Firefox) navigate to https://rspm.analyticsenclave.org/client/#/

Click on the Get Started tab.

Navigate to prod-cran.

Click on the Setup tab from the sub-menu.

You may configure your RStudio environment with RSPM in different ways. For example: (1) using only the latest packages from a repository (https://rspm.analyticsenclave.org/prod-cran/latest), (2) using a set of packages from a fixed version of a repository, or (3) using binary or source packages.

Use binary package installations from RSPM wherever possible to speed up deployment time.

 

Each repository in RSPM will contain a Setup web page with instructions for configuring R to use RSPM. Once configured, you can access packages using standard functions such as install. Packages(), available. Packages(), packrak, and renv.

The repositories in RSPM are CRAN-like repositories thus you can use the usual R functions to access, query, and install packages.

Step 2 Configuring RSPM repositories.

Install the system prerequisites for the repo’s packages.

Version Selection.

Selecting specific version of R as depicted in the diagram below. When you switch versions, remember to save your workspace before restarting the session to access the newly selected version of R you want to use. As of August 2021, the available versions are R 3.6.3 and R 4.0.4.

Using Packages INSIDE RStudio.

In RStudio, go to the Tools section of the main toolbar and select Global Options. In the Packages sub-menu, the Primary CRAN repo is preset to Global (CDN) – RStudio. Click Add and type in the name and repository URL of the secondary repository and click OK.

For projects requiring strict reproducibility, RStudio Support recommends configuring R to use a repository URL with a transaction ID. Versioning is available for all repository and source types.

 

Example 1: Installing ggplot2, a popular graphics package in R.

You can also run the following command install.packages("ggplot2") from the Console.

Example 2 – Installing shiny.

You can also run the following command install.packages("shiny") from the Console.

Using Packages OUTSIDE RStudio.

To configure R outside of RStudio, you can make use of the RSPM guided setup as follows.

  1. Click Setup
  2. Click prod-cran repository mirror
  3. Choose your Distribution (OS)
  4. Click Latest

Scroll down and follow the tailored RSPM instructions on the page based on your selections.

Add the following line to your R startup file (Rprofile.site or .Rprofile) to maintain the configuration across R sessions.

Step 3 Using RSPM to Search for Packages

RSPM is a public mirror of CRAN, Bioconductor and Pypi public repositories.

As such, RSPM simplifies the search for (and installation of) packages right from its Web UI, let's use it to search for the R package dplyr as follows :

As you can see, the Overview page provides important details such as installation code, source file, binary file and available versions of the package(s).

You may even download the OS-specific binary version of the package:

  1. Change the Operating System selection
  2. Change the R version

Escalation:

Contact the service desk to have ticket escalated to the Enclave Platform - MGB assignment group.

Relevant References

  1. RStudio Package Manager Webinar - Introduction to the RStudio Package Manager
  2. Managing R with .Rprofile, .Renviron, Rprofile.site, Renviron.site, rsession.conf, and repos.conf
  3. R Markdown Reference Guide
Go to KB0040284 in the IS Service Desk

Related articles

Analytics Enclave

IDEA Platform