Colonel Panic
Colonel Panic

Reputation: 137782

R install package globally

How do I install an R package globally, so it's available to all users? Currently I'm doing

R.exe CMD INSTALL *.zip

But it does

* installing to library 'C:/Users/Matt/Documents/R/win-library/2.15'

I would like to install the packages alongside R in Windows' 'program files'.

Upvotes: 14

Views: 21397

Answers (3)

Mike Monteiro
Mike Monteiro

Reputation: 1457

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

Upvotes: 6

Fhnuzoag
Fhnuzoag

Reputation: 3920

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.

Upvotes: 8

jey1401
jey1401

Reputation: 371

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

Upvotes: 1

Related Questions