On 13-02-15 9:54 AM, Rainer M Krug wrote: On 15/02/13 15:41, Duncan Murdoch wrote:
On 13-02-15 9:28 AM, Rainer M Krug wrote: Hi
I am sure I am missing something really basic, but I can't figure it out.
I want to start R so that I can specify the location for the Library tree. In principel
simple:
As I only want it dependent on the directory I stat R in, I put a .Rprofile file in the
directory.
My default path is:
[1] "/home/rkrug/R/i686-pc-linux-gnu-library/2.15" [2] "/usr/lib/R/site-library" [3]
"/usr/lib/R/library"
[1] "/home/rkrug/THE_DIRECTORY/library" [2] "/usr/lib/R/library"
The first part is easy:
.libPaths("/home/rkrug/THE_DIRECTORY/library")
but how can I remove the site library?
If I set
In R 15.2 under Ubuntu, started with
R --vanilla
[1] "/home/rkrug/R/i686-pc-linux-gnu-library/2.15" [2] "/usr/lib/R/site-library" [3]
"/usr/lib/R/library"
[1] "/usr/lib/R/site-library" "/usr/lib/R/library"
.Library.site <- "" .Library.site
[1] "/home/rkrug/R/i686-pc-linux-gnu-library/2.15" [2] "/usr/lib/R/site-library" [3]
"/usr/lib/R/library"
.libPaths("") .libPaths()
[1] "/usr/lib/R/site-library" "/usr/lib/R/library"
.libPaths("") .libPaths()
[1] "/usr/lib/R/site-library" "/usr/lib/R/library"
does not change anything.
Am I missing something or is there a bug in .libPaths()?
I don't think there is a bug. As ?.libPaths says,
"Function .libPaths always uses the values of .Library and .Library.site in the base
namespace. .Library.site can be set by the site in ?Rprofile.site?, which should be
followed by a call to .libPaths(.libPaths()) to make use of the updated value."
So you can't change the value of .Library.site after starting R. You'll need to use
environment variables (as described on that page) to do it.
Thanks for the clarification - the use of the word "site" in "set by the site in
?Rprofile.site? " was not clear to me. I thik it would be much clearer, if it states that the
variables .Library and .Library.site can not be changed while R is running although it looks as
if they can be changed (but then new ones in the top environment are created).
Now just one more question: where can I see that
.Library <- "/A/New/Existing/Directory"
has no impact?
If you look at environment(.libPaths) you'll see that it is not .GlobalEnv, so the .lib.loc
assignment might not happen where you think. Indeed,
ls(environment(.libPaths), all=TRUE)
will show that it contains one object, .lib.loc. You can modify that variable, but it's
quite a risky (in the sense of being undocumented and unsupported) thing to do.