R: combining the location of several libraries with most modern packages

Question: How to transfer all the most modern R packages to one simple place that R (and everything else) will use now and forever for my packages?

I played with R on Ubuntu 10.04 using different RGedit, RCmdr, R shell and RStudio. Meanwhile, I installed packages, updated packages, and updated packages through apt, synaptic, install.packages (), etc., which, apparently, mean that these packages are placed everywhere and (in case of accidental noise) with different permissions .

I currently have different versions of different (and duplicate) packages:

/home/me/R/i486-pc-linux-gnu-library/2.10 /home/me/R/i486-pc-linux-gnu-library/2.14 /home/me/R/i486-pc-linux-gnu-library/ /usr/local/lib/R/site-library /usr/lib/R/site-library /usr/lib/R/library 

At first - I am one user, on one machine - I do not need several places in the library, I just want it to work.

Secondly - I am in an extremely slow connection and cannot continue to simply download packages again.

So - is there an easy way to combine all of these library locations into one simple place? Can I just copy folders?

How to install it in concrete, what is it and will always be, where everything connected by R searches for and updates packages?

This is madness.

Thanks for your help.

+6
source share
2 answers

After collecting various bits of information, here goes: The complete moron guide to organizing R package directories:

NB1 is my experience with Ubuntu - your mileage may vary NB2 - I am one user on the same machine and I really like things.

Ubuntu puts everything installed through apt or synaptic in:

 /usr/lib/R/site-library /usr/lib/R/library 

directories. By default, vanilla R install will try to install packages here:

 /usr/local/lib/R/site-library 

Since these are system directories, the user does not have write privileges, depending on which method you interact with R, you may be offered a friendly - "Hello, buddy, we can’t write there, you want us to put your packages in your home directory? " which seems innocent and reasonable enough ... if you never change your GUI or your work environment. If you do this, the new GUI / environment may not look in the directory where the packages were placed, so it won’t find them. (Most interfaces have a way to indicate where your personal package library is located, but who wants to put it out in configuration files?)

What seems best to me (and feel free to fix me if I'm wrong) with installing the default installation in Ubuntu is to do any package management from the main R shell in the form of sudo: > sudo R and from there make your install.packages() voodoo. It seems that the packages are placed in the usr/local/lib/R/site-library directory.

At the same time, update.packages() will update files in the /usr/lib/R/site-library and usr/lib/R/library directories, as well as usr/local/lib/R/site-library

(Regarding the usr/lib/R/ partition, it looks like /library/ has the base packages, and /site-library/ contains something added, assuming they were installed apt ...)

Any packages previously installed and in the wrong place can be moved to the /usr/local/lib/R/site-library directory (if you sudo it) simply by moving directories (thanks @Tommy), but since usr/lib/R/ controlled by apt - it’s better not to add or subtract from there ...

Phew In any case, a fairly simple and simple language. Thank you all for your help.

+4
source

Yes, it should almost work to just copy folders. But pre-2.14 packages without a NAMESPACE file will probably not work in R 2.14, where all packages must have a namespace ...

And you want to manually make sure that you only copy the latest version of each package, if you have multiple versions ...

If you type .libPaths() , it will tell you where R is looking for packages. The first on the list is where new packages are usually installed. I suspect .libPaths() may return different things from RStudio vs. Rcmd etc.

+7
source

Source: https://habr.com/ru/post/904013/


All Articles