|Is there a life outside the office?
Photo: Markus Gesmann
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:\Programme Files" folder. That ment that R couldn’t install any packages into the default directory
"C:\Programme Files\R\R-X.Y.Z\library" (replace
R-X.Y.Z with the version number of R installed).
Never-mind, there is an option for that, the
libs argument in the
install.packages function. But then I have to use the same argument also in the
library statement. 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:\Users\MyNAME\R, 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.
The next step is to enable R to execute the above command at start up. For that I created the R file
C:\Users\MyNAME\R\Rconfigure_default.R with 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"<br />
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.