David B
David B

Reputation: 29998

Installing R packages available for all users

I have a few R packages installed under ~/R/i486-pc-linux-gnu-library/2.11.

I would like to make them, and any other R package I install from now on, available to all R users. I don't mind re-installing the packages I already have in a neutral place (they are just a few). So how do I do that?

Upvotes: 28

Views: 23996

Answers (3)

Feri
Feri

Reputation: 250

In your case, the easiest way would be to install the packages as root (or as administrator in case of Windows), they'll be available for every user on that machine.

Upvotes: 2

mbq
mbq

Reputation: 18628

aL3xa answer is wrong; you shouldn't expose those directories to write for all users.
Run R as a root (probably using sudo R) and then install packages as usual -- they will be placed in a global library and will be available for all users.

Upvotes: 9

Dirk is no longer here
Dirk is no longer here

Reputation: 368251

aL3xa gives (IMHO) bad advice. Do not mess with /usr which is handled by the package management system. Instead, use the facility provided by /usr/local/lib/R/site-library.

That latter directory is already searched by default. All you need to do is to add yourself to group staff as that group has write-rights there -- try adduser yourid staff where yourid is your user name on the system. Afterwards you should be able to install there without problems.

Another thing you may like on Ubuntu is apt-get install littler and then use the install.r and upgrade.r helper scripts from the examples directory. I use them all the time.

Upvotes: 33

Related Questions