Robert's Data Science Blog

Multiple R Installations on Windows

I have written about how to install multiple versions of R on Linux. Now the time has come to Windows.

Installing different version of R on Windows is easy – just download the installer and choose an installation folder. If the bleeding edge on r-project is not the right version, then take a look at the previous releases of R for Windows.

I want the same “post installation” tweaks on both platforms:

User package library

The default library used to install packages is the environment variable R_LIBS_USER that is set in the system wide Rprofile. To overwrite R_LIBS_USER for a user, it should be defined in the “user wide” Renviron file located in the user’s “home folder”.

I often struggle to find my “home folder” on Windows, since a location like “Documents” in Explorer doesn’t write its actual path. Luckily, R can help locate the folder that R thinks is the home folder using either base R:

file.edit(file.path("~", ".Renviron"))

or the usethis package:

usethis::edit_r_environ()

Just like on Linux I specify the path using “specifiers”:

R_LIBS_USER=~/R/%p-library/%V

CRAN

I use the default installation folder in Program Files. Here I consider R version 3.5.3 that is located in C:\Program Files\R\R-3.5.3.

The Rprofile is in C:\Program Files\R\R-3.5.3\etc\Rprofile.site. In the bottom of Rprofile.site I set the package repository:

options(repos = "https://mran.microsoft.com/snapshot/2019-04-25")

I find the appropriate date by looking in the Version-stable Rocker images .