R install package globally
Solution 1
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.
Solution 2
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
Solution 3
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
Related videos on Youtube
Colonel Panic
If you really want to understand something, the best way is to try and explain it to someone else. That forces you to sort it out in your mind. And the more slow and dim-witted your pupil, the more you have to break things down into more and more simple ideas. And that's really the essence of programming. By the time you've sorted out a complicated idea into little steps that even a stupid machine can deal with, you've learned something about it yourself. —Douglas Adams
Updated on September 14, 2022Comments
-
Colonel Panic over 1 year
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'.
-
Colonel Panic almost 12 yearsWhat should I put for the argument lib? I have R installed at
"C:\Program Files\R\bin\x64\R.exe"
-
-
Colonel Panic almost 12 yearsI didn't know
C:
differs. If I give users permission to write toC:\Program Files\R
then will packages install there by default? I did this for my Python and Ruby installations -
Armen Michaeli almost 4 years"recommend you install R to C:\R": for a personal computer and no other users -- maybe. In a cluster of orchestrated systems where file permissions are actually there to help, to prevent regular users from messing up software installations -- do not install anything in C:\ where file permissions are relaxed for legacy reasons. Install in %Program Files% so that people can't mess up the software installed there. It's a better design. In fact it's better for personal computers too. This isn't DOS.
-
Josiah Yoder over 3 yearsI think it would be better to recommend running R as an administrator than to use a non-standard install location.
-
Fhnuzoag over 3 yearsBack when I left this response I was thinking about the situation where you are a student installing R on to a personal laptop. IIRC, the main convenience of installing the package into the same directory as R is that you have essentially a portable R installation that you can transfer to a different computer on a thumbstick, say. Running R as admin is non-ideal because of (a) security concerns with malicious packages and (b) it's not retrospective, you have to restart R.