Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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'.

like image 479
Colonel Panic Avatar asked May 30 '12 15:05

Colonel Panic


3 Answers

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.

like image 120
Fhnuzoag Avatar answered Nov 18 '22 14:11

Fhnuzoag


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

like image 4
Mike Monteiro Avatar answered Nov 18 '22 12:11

Mike Monteiro


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

like image 1
jey1401 Avatar answered Nov 18 '22 12:11

jey1401