Question

some background: I'm a fairly beginning sysadmin maintaining the server for our department. The server houses several VM's, mostly Ubuntu SE 12.04, usually with a separate VM per project.

One of the tools we use is R and RStudio, also server edition. I've set this up so everyone can access it through their browser, but I'm still wondering what the best way would be to deal with package management. Ideally, I will have one folder/library with our "common" packages, which are common in many projects and use cases. I would admin this library, since I'm the only user in sudo. My colleagues should be able to add packages on a case-by-case basis in their "personal" R folders, that get checked as a backup in case a certain package is not available in our main folder.

My question has a few parts: - Is this actually a viable way to set this up? - How would I configure this? - Is there a way to easily automate this library for use in other VM's?

I have a similar question pertaining to Python, but maybe I should make a new question for that..

Was it helpful?

Solution

R supports multiple libaries for packages by default. Libraries are basically just folders in which installed packages are placed. You can use

.libPaths() 

in R to view what paths are use as libraries on your system. On my Ubuntu 13.10 system, there are

  • a personal library at "~/R/x86_64-pc-linux-gnu-library/3.0" where packages installed by the user are placed,
  • "/usr/lib/R/library" where packages installed via apt-get are placed and
  • "/usr/lib/R/site-library" which is a system-wide library for packages that are shared by all users.

You can add additional libraries to R, but from how I understand your question, installing packages to /usr/lib/R/site-library might be what you are looking for. This can be archived relatively easily by running R as root and calling install.packages() and update.packages() from there as usual. However, running R as root is a security risk and not a good idea, so maybe it is better to create an separate user with write access to /usr/lib/R/site-library and to use that one instead of root.

If you mount /usr/lib/R/site-library on multiple VM, they should also share the packages installed there. Does this answer your question?

OTHER TIPS

Having common library and personal library locations is completely feasible.

Each user should have two environment variables set. R_LIBS should point to the common library, and R_LIBS_USER should point to their personal location. See ?.Library for more information.

You can check a user's library paths using .libPaths(). You probably want users to install packages to their personal library, so some fiddling may be required to make sure that the personal library is the first element in of .libPaths().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top