Re: [R] scripts with littler

From: Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Wed 10 Jan 2007 - 14:05:33 GMT

[By now way off the subject line. Something like 'how to set the libraries inside an R session'.]

On Wed, 10 Jan 2007, John Lawrence Aspden wrote:

> John Lawrence Aspden wrote:
>
>> I've got a library (brainwaver), installed locally in ~/R/library, and
>> this information is recorded in the ~/.Renviron file.
>
>> In my script I load the library, but if I call it using
>> #!/usr/bin/r --vanilla, this stops working.
>
> (Various private e-mails exchanged. Again, thanks Dirk!)
>
> Just in case anyone else is trying to do this, it turns out that if you can
> persuade your end users to install the library to ~/R/library, then you can
> say:
>
> #!/usr/bin/r --vanilla
> library(brainwaver, lib.loc='~/R/library')
>
> although in my case, brainwaver depends on another library, which it now
> can't find, so actually I have to load them in order:
>
> #!/usr/bin/r --vanilla
>
> library(waveslim, lib.loc='~/R/library')
> library(brainwaver, lib.loc='~/R/library')
>
> Alternatively,
>
> #!/usr/bin/r --vanilla
>
> .libPaths('~/R/library')
> library(brainwaver)
>
> works, although be careful, I've noticed that it seems to behave a bit
> strangely on my debian setup.

'It' (R) is behaving as you asked it to. Most likely you intended to ask for

.libPaths(c("~/R/library", .libPaths()))

> e.g.
>
> #!/usr/bin/r --vanilla
> cat(.Library,'*****', .libPaths(),"\n")
> .libPaths('~/R/library')
> cat(.Library,'*****', .libPaths(),"\n")
>
> gives output
> /usr/lib/R/library
> ***** /usr/local/lib/R/site-library /usr/lib/R/site-library /usr/lib/R/library
> /usr/lib/R/library ***** ~/R/library /usr/lib/R/library
>
> that is, it seems to have removed /usr/local/lib/R/site-library
> and /usr/lib/R/site-library as well as added ~/R/library

Exactly as documented. The argument is named 'new' and not 'add', BTW. Please 'be careful' in what you say about the work of others.

>
> Cheers, John.
>
>

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Thu Jan 11 01:18:13 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 10 Jan 2007 - 18:30:25 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.