R install package globally R install package globally windows windows

R install package globally


Your big problem here is installing to C:\Program Files\. This means on versions of windows with file permissions, you need admin permissions to write to that folder. As R does not commonly request admin permissions, it will on default install to an user subdirectory, unless you run R as administrator (by right clicking on the shortcut). In which case you can use the GUI to install packages and it will install them globally by default. For working on the command line, you can also run the cmd session as administrator.

In future, it's recommended that you install R to say, C:\R\ to avoid this.


What worked for me was running:

install.packages("MyPackage", lib="C:\\Program Files\\R\\R-3.0.1\\library")

Installing it to Program Files wasn't a problem for me - the problem was that the default installation directory was in C:\\Users\\Mike\\Documents\\R\\...

Ultimately you just want to install it to wherever .libPaths() looks by default, and in my environment that was most commonly C:\\Program Files\\R\\R-3.0.1\\library


Here is a way to specify where to find or install libraries. You can put the libraries in a common directory.

http://cran.r-project.org/doc/manuals/R-admin.html#Managing-libraries