How do I use R in the VDE? It’s different than what I’m used to on my personal machine.

ICPSR maintains the latest installations of both R for Windows and RStudio Desktop in the VDE. Continue reading to learn more about some of the more advanced details of working with R in the VDE. Some things may be different than you are used to based on the security requirements of the VDE. If you need general help with R, we recommend the R-Project’s help page or manuals as good places to start.

Repository Packages, CRAN, and Ralt

About Packages

Packages are collections of R functions, data, and programming code. They are installed in libraries. A library is a file system directory that contains a subdirectory for each package. R provides a main library, R_HOME/library, that contains a set of standard and recommended packages. Your analyses may require packages that are not included in that main library. You obtain additional packages from a package repository and install them to your personal library.

VDE Restrictions

Because the ICPSR virtual data enclave (VDE) is on an isolated network, you are not able to access repositories on the internet. ICPSR provides a mirror of the CRAN repository within the VDE. Upon request, ICPSR will provide packages that are not distributed through the CRAN repository.

ICPSR has the CRAN repository automatically mapped as the “R:” drive in Windows. ICPSR’s installation of R in the VDE is automatically configured to be used as the source to install any package that is in the CRAN repository.

Non-CRAN Packages

ICPSR also maintains the “Ralt” folder in the R drive as a home for non-CRAN R packages. Please be mindful that any non-CRAN package must be manually added to the Ralt folder by a human. This process can take some time, and must be manually requested. Please open a support request by emailing icpsr-help@umich.edu. In the body of that email, please include the following items:

  • Your VDE username
  • The name of the package you need installed
  • A link to the github repository
  • Any installation instructions, especially if it is not just using devtools::install_github(author/repo)
  • Any other notes, such as known non-CRAN dependencies

Package Management

About Libraries

Packages are installed in libraries. A library is a file system directory that contains a subdirectory for each package. R provides a main library that contains a set of standard and recommended packages. you can install additional packages to one or more personal libraries. By default, R creates your personal library in your home directory at

%USERPROFILE%DocumentsRwin-libraryx.y}, where {x.y} indicates the installed version of R.

Best Practices for Libraries

ICPSR recommends that you DO NOT use the default personal library. A disk quota is imposed on your VDE home directory and you may exhaust all available storage space if you install a large number of R packages. Instead, create a personal library in your VDE project folder. For example, if you want to install packages to H:RR_Lib, create those subfolders. Next, edit your .Rprofile to add your library to the library search path. R can access installed packages that are included in the library search path. That search path is initialized at startup. You can display the library search path in R with the command.

.libPaths()

Installing Packages

The install.packages() command installs packages to the first element of .libPaths() unless a library is supplied as an argument. If you have setup your .Rprofile as above, then this will be in H:/R/R_Lib.

Each package that you install consumes some of your allocated storage. Install only the packages that you need and uninstall them when you no longer need them. ICPSR recommends that users create their personal library in their project folder and configure their .Rprofile prior to attempting to install packages from the repository. Installing packages to the default location in your documents can cause issues as your Documents folder is under a much smaller quota than your Project directory.

A precompiled binary package for the Windows operating system has a *.zip filename extension. To install it, use the R command install.packages(). Provide the full file path to the package binary. Add the argument repos = NULL because the package is not supplied from a repository. For example, assume that you want to use a package demoxyz which is not part of the CRAN repository. You would install it to your personal library using the following command:

install.packages("R:/Ralt/demoxyz.zip", repos = NULL)

In some cases it may be more complicated to install a non-CRAN package, in which case ICPSR will provide a readme file. This file will be in the R:Ralt folder and named package_name_readme.txt or similar. Please read those readmes or that package probably won’t install correctly!

.Rprofile and Startup Configuration

About .Rprofile

You can use the .Rprofile file to configure your R workspace. You can use that file to add your personal library to the library search path. If you have an existing .Rprofile file in your home directory, open it in Notepad. Otherwise, open Notepad so that you can create the file. Add a new line to the file to define a library search path that includes your personal library. If your personal library is located in your project folder (mapped to drive letter H: in the folder RR_Lib then you would add the following command to .Rprofile.

.libPaths(c("H:/R/R_Lib", .libPaths()))

If you have multiple libraries to add, your .Rprofile will look like this instead.

.libPaths(c("H:/R/R_Lib", "H:/Other/Library/Path/Here", .libPaths()))

If you defined a different location for your personal library, edit the command accordingly. Save .Rprofile to your Documents folder. The settings in your .Rprofile will be applied everytime that R is launched.

Rstudio Issues

RMarkdown Installation

If you need to install RMarkdown, attempting to do so through RStudio will not respect the .rprofile.site file that tells R to use the R: drive as a package repository. Instead, please do:

install.packages(c('base64enc', 'digest', 'evaluate', 'glue', 'highr', 'htmltools', 'jquerylib', 'jsonlite', 'knitr', 'magrittr', 'markdown', 'mime', 'rmarkdown', 'stringi', 'stringr', 'tinytex', 'xfun', 'yaml'))

Blank Window or Crashes

If you encounter a blank window, or Rstudio crashes to desktop, first check that you followed the steps above for RMarkdown Installation if you are using RMarkdown. If that is not the cause, please see the following PDF outlining steps to resolve a compatibility issue with the Omnissa Horizon Graphics Driver.