I have read the R FAQS and other posts but I am a bit confused and would be grateful to know whether I did everything correctly.
In Windows, in order to modify the default library folder I created a file Renviron.site
and put inside E:/Programs/R-3.3.0/etc
.
The file has only one line saying
R_LIBS=E:/Rlibrary
When I open R and run .libPaths()
I see E:/Rlibrary
as [1] and the default R library E:/Programs/R-3.3.0/library
as [2].
This should mean that from now on all packages I will install will go in E:/Rlibrary
but at the same time I will be able to load and use both packages in this folder and those in the default location. Am I correct?
When you load a package via library
, it will go through each directory in .libPaths()
in turn to find the required package. If the package hasn't been found, you will get an error. This means you can have multiple versions of a package (in different directories), but the package that will be used is determined by the order of .libPaths()
.
Regarding how .libPaths()
is constructed, from ?.R_LIBS
The library search path is initialized at startup from the environment variable 'R_LIBS' (which should be a colon-separated list of directories at which R library trees are rooted) followed by those in environment variable 'R_LIBS_USER'. Only directories which exist at the time will be included.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With