[R] Loading functions in R

Matthew Keller mckellercran at gmail.com
Thu Feb 1 16:16:03 CET 2007


Hi Jeff,

The way I do this is to place all the options that I want, along with
functions I've written that I always want available, into the
"Rprofile.site" file. R always loads this file upon startup. That file
is located in the etc/ folder. E.g., on my computer, it is at:
C:\Program Files\R\R-2.2.1\etc\Rprofile.site . This is explained in
section 10.8 of the R-intro.pdf manual that comes with R.

If you only want the functions available sometimes, then use Christos'
suggestions.

-- Matt


On 1/31/07, Christos Hatzis <christos at nuverabio.com> wrote:
> The recommended approach is to make a package for your functions that will
> include documentation, error checks etc.
> Another way to accomplish what you want is to start a new R session and
> 'source' your .R files and then to save the workspace in a .RData file, e.g.
> myFunctions.RData.
>
> Finally
>
> attach(myFunctions.RData)
>
> should do the trick without cluttering your workspace.
>
> -Christos
>
> Christos Hatzis, Ph.D.
> Nuvera Biosciences, Inc.
> 400 West Cummings Park
> Suite 5350
> Woburn, MA 01801
> Tel: 781-938-3830
> www.nuverabio.com
>
>
>
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Forest Floor
> Sent: Wednesday, January 31, 2007 10:41 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] Loading functions in R
>
> Hi all,
>
> This information must be out there, but I can't seem to find it.  What I
> want to do is to store functions I've created (as .R files or in whatever
> form) and then load them when I need them (or on startup) so that I can
> access without cluttering my program with the function code.
> This seems like it should be easy, but....
>
> Thanks!
>
> Jeff
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list