6 followers Follow

Changing Default packages instalation directory in R studio

How to change the default package installation directory by using R studio, could any body help me in this regard.

Muhammad Yousaf Khan

Official comment


Hi Muhammad,

This is actually something that is controlled by your R installation rather than RStudio - for how you'd go about doing it, please check out the available documentation from the R project: and
You might also find the following resources helpful for getting help with this and with R in general:


Ian Pylvainen
Comment actions Permalink



Windows 7: If your C:\Program Files (or wherever R is installed) is blocked for writing, as mine is, then you'll get frustrated editing (as I did). Even after reading the fine manual several times and extensive searching, it took me several hours to do this, mainly because I don't quite understand all the lingo that the experts use in the manuals. In the spirit of saving someone else time...

How to edit R_LIBS_USER to change where your package library resides:

Let's assume you want your packages to reside in C:\R\Library:

  1. Create the folder C:\R\Library
  2. Click Start --> Control Panel --> User Accounts --> Change my environmental variables
  3. The Environmental Variables window pops up. If you see R_LIBS_USER, highlight it and click Edit. Otherwise click New. Both actions open a window with fields for Variable and Value.
  4. In my case, R_LIBS_USER was already there, and the value was a path to my desktop. I added to the path the folder that I created, separated by semicolon. No quotes:  C:\R\Library;C:\Users\Eric.Krantz\Desktop\R stuff\Packages. NOTE: I could have removed the path to the Desktop location and simply left C:\R\Library.
Eric Krantz 3 votes
Comment actions Permalink

Many thanks to Eric Krantz, I got it to work! Enviroment variables are the key.

Nick 1 vote
Comment actions Permalink

Hi All,

Please somebody can help me.

I'm using MacBook Pro. How can i do to change default packages instalation directory in R or RStudio.?

Somebody have a tutorial?

Best regards

attoumand 1 vote
Comment actions Permalink