[R] How to make own function load automatically on startup

Gabor Csardi csardi at rmki.kfki.hu
Sat Oct 27 20:50:36 CEST 2007


Jonas, if you want the function to load really automatically, 
without running source of anything, read 

?Startup

Basically you need to create an .Rprofile file (its location depends
on your operating system) containing the R code you want to run
at startup.

Gabor

On Sat, Oct 27, 2007 at 08:37:13PM +0200, Katharine Mullen wrote:
> Regarding your first issue:
> you could make a package to contain your function (see ?package.skeleton
> and the manual "Writing R extensions") - then you could use
> library(yourpackagename).  Or you could save the definition of your
> function(s) in a text file, and use source("textfilename") to load the
> definition(s) after you start R.
> 
> Regarding your third issue:
> see help("::")
> 
> On Sat, 27 Oct 2007, Jonas Malmros wrote:
> 
> > Dear list members,
> >
> > I have written a function, called say Analysis. I supply an Excel file
> > name as an argument, it does analysis on this file and returns a pdf
> > file with specific plots, and a text file with several statistical
> > models' output (I extract certain values from the output and create my
> > own custom dataframe with output).
> >
> > As of now I have to open the script file and load the function by hand
> > every time I start R. I want to make it load automatically into the
> > environment when I start R. How can I make this happen?
> >
> > Also, is there a simple way to combine plots and my custom dataframe
> > with model output in one pdf file? I do use LaTeX, but my collegues
> > who want to run this function as well do not know what LaTeX is. So I
> > wonder if I can avoid LaTeX when creating this combined PDF file?
> > (Avoid in the sense that one does not have to fiddle with LaTeX
> > itself).
> >
> > Finally, another small question.
> > My code contains following snippet: "xlsReadWrite::read.xls", this is
> > because another package I load masks read.xls function and :: help me
> > to select correct read.xls. I guessed this use of :: but I would
> > really like to know what :: is and where can I read more about this
> > function?
> >
> > Thank you very much in advance for your time and help!
> >
> > --
> > Jonas Malmros
> > Stockholm University
> > Stockholm, Sweden
> >
> > ______________________________________________
> > R-help at r-project.org 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 r-project.org 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.

-- 
Csardi Gabor <csardi at rmki.kfki.hu>    MTA RMKI, ELTE TTK



More information about the R-help mailing list