Downloading packages to external hard drive

Dear All,

I am quite new to R and and have only been introduced it quite recently at university. I have just installed Rstudio on external hard drive since my macbook did not have enough disk space however I cannot seem to change download location of any of Rstudio's packages. I wish to for example load data from excel..however I am unable to do this as I need a particular package to do so. Thus I seem to be stuck..is it at all possible to download studio packages externally?

Apologies.if this seems like a trivial question.

Hi @Adrikimi,

Change the .libPaths() location to where you would like packages to install.

.libPaths(new = "path/goes/here")

The function install.packages() will look to .libPaths() and take the first element of .libPaths() when installing packages.

To complement @mattwarkentin's comment, using .libPaths() is only going to work on your current R session, the next time you start R things are going back to the default locations, so if you want to make this change persistent, you can add this environmental variable to your Renviron.site file, or add the .libPaths() command to your Rprofile.site file.

# Set library path
R_LIBS_SITE="path/goes/here"

Some information about this startup configuration files

https://cran.r-project.org/web/packages/startup/vignettes/startup-intro.html

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.