[R] Introduce a new function in a package?

Jan T. Kim jtk at cmp.uea.ac.uk
Wed Apr 6 17:09:34 CEST 2005


On Wed, Apr 06, 2005 at 09:57:00AM -0400, Roger D. Peng wrote:
> I think the usual way is to create an R package for yourself and load 
> it when you need it for whatever project.
> 
> -roger

Alternatively, one can also write the function in question into one's
~/.Rprofile; then, it's automatically available in all R sessions.
To avoid confusion, make sure that you choose a unique name, i.e. one
that isn't used by any package, if possible.

This method should be used only for functions intended to provide some
convenience in interactive sessions, code in scripts should not rely
on functions being provided by ~/.Rprofile. For scripting, an R package
is definitely preferred.

Best regards, Jan

> Luis Ridao Cruz wrote:
> >R-help,
> >
> >Sometimes I define functions I wish to have in any R session.
> >The obvious thing to do is copy-paste the code 
> >The thing is that sometimes I don't know where I have the function
> >code.
> >
> >My question is if somehow I could define a function and "introduce" it
> >(let's say 'base' package ) so that 
> >could be used anytime I run a different R project.
> >
> >Thank you in advance
> >
> >______________________________________________
> >R-help at 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
> >
> 
> ______________________________________________
> R-help at 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

-- 
 +- Jan T. Kim -------------------------------------------------------+
 |    *NEW*    email: jtk at cmp.uea.ac.uk                               |
 |    *NEW*    WWW:   http://www.cmp.uea.ac.uk/people/jtk             |
 *-----=<  hierarchical systems are for files, not for humans  >=-----*




More information about the R-help mailing list