R install package globally

Colonel Panic picture Colonel Panic · May 30, 2012 · Viewed 13.8k times · Source

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

Answer

Fhnuzoag picture Fhnuzoag · May 30, 2012

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.