Search Docs by Keyword

Table of Contents

R and RStudio on Windows

R packages in RStudio are user-based and not installed globally to all users.

To install packages in RStudio, you simply

> install.packages("data.table")

This will install a package in a user library, something like C:/Users/jharvard/AppData/Local/R/win-library/4.2.

If you are using a secure system and the library cannot be downloaded, check that you have the correct proxies:

> Sys.getenv("http_proxy")
> Sys.getenv("https_proxy")

If those variables are empty, set them with:

> Sys.setenv(http_proxy="http://rcproxy.rc.fas.harvard.edu:3128")
> Sys.setenv(https_proxy="http://rcproxy.rc.fas.harvard.edu:3128")

Then, try installing again, with a specific CRAN repo that we allow, https://cloud.r-project.org.  For example:

> install.packages("data.table", repos='https://cloud.r-project.org')

If a window pops and asks for which mirror to download from, choose “cloud” otherwise the installation will fail.

Alternatively, you can permanently set your CRAN mirror to cloud by going to Tools -> Global Options -> Packages. On the “Management” tab, Primary CRAN repository, click “Change”. Under “Custom” type https://cloud.r-project.org/. Click OK, OK. You will have to restart RStudio for this change to take effect.

 

© The President and Fellows of Harvard College
Except where otherwise noted, this content is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International license.