Installing R packages without admin rights on MS Windows
It is not unusual that you will not have admin rights in an IT controlled office environment. But then again the limitations set by the IT department can spark of some creativity. And I have to admit that I enjoy this kind of troubleshooting.The other day I ended up in front of a Windows PC with R installed, but a locked down
“C:Files”folder. That meant that R couldn’t install any packages into the default directory
R-X.Y.Zwith the version number of R installed).
Never-mind, there is an option for that, the
libs argument in the
install.packages function. However, I have to use the same argument also in the
library statement then as well. Fair enough, yet it is more convenient to set the directory somewhere globally.
First of all I decided that I wanted to install my R packages into
C:, a folder to which I had read/write access (replace
MyNAME, or the whole path with what works for you). The R command
.libPaths(c(“C:\Users\MyNAME\R”, .libPaths())) will make this directory the default directory for any additional packages I may want to install, and as it is put at the front of my search path,
library will find them first as well.
C:_default.Rwith the following content:
Finally I added a new shortcut to
Rgui.exe to my desktop with the target set to:
"C:\Program Files\R\R-2.X.Y\bin\i386\Rgui.exe" R_PROFILE_USER="C:\Users\MyNAME\R\Rconfigure_default.r"
Job done. R will happily install any new packages locally and find them as well when I use
require. For more information see also the R FAQs.