Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing R packages available for all users

Tags:

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?

like image 692
David B Avatar asked Aug 15 '10 12:08

David B


People also ask

How can we install packages in R with all dependencies?

Remember in R, Boolean (TRUE and FALSE) must be all capital letters or R will not recognize them as Boolean. At the top, got to Tools and select Install Packages from the drop down. Finally, make sure install dependencies and checked and click install.

Why can't I install packages in RStudio?

Solution 2: Use RStudioChanging the configuration in R Studio to solve install packages issue. Go To Tools -> Global option -> Packages. Then uncheck the option “Use secure download method for HTTP”. For other RStudio issues refer to official Troubleshooting Guide here.

Do you have to install packages every time you use R?

You only need to install packages the first time you use R (or after updating to a new version). **R Tip:** You can just type this into the command line of R to install each package. Once a package is installed, you don't have to install it again while using the version of R!

How do I install all packages in R?

You can install multiple packages by passing a vector of package names to the function, for example, install. packages(c("dplyr", "stringr")) . That function will install the requested packages, along with any of their non-optional dependencies.


2 Answers

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.

like image 188
Dirk Eddelbuettel Avatar answered Jan 25 '23 18:01

Dirk Eddelbuettel


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.

like image 27
mbq Avatar answered Jan 25 '23 17:01

mbq