[R] Introduce a new function in a package?

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Apr 6 17:53:21 CEST 2005


Better to attach a new environment and source() the files into that.

local({
   for (.x in dir("Mylibrary",full.names=T,recursive=T))
      source(.x, local=T); rm(.x)},
   env = attach(NULL, name="myenv"))

for all the reasons why a package() is a good idea.

Leaving an object `x' around from .Rprofile is not at all a good idea, 
BTW.

On Wed, 6 Apr 2005, Josef Eschgfaeller wrote:

>
>> ~/.Rprofile
>
> You could also write in .Rprofile soemthing like this:
>
> for (x in dir("Mylibrary",full.names=T,recursive=T))
>  source(x)
>
> where "Mylibrary" is a directory which
> contains your functions without making a package.
>
> Josef Eschgfäller

-- 
Brian D. Ripley,                  ripley at 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


More information about the R-help mailing list