Jonas Malmros
2007-Oct-27 16:02 UTC
[R] How to make own function load automatically on startup
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
Katharine Mullen
2007-Oct-27 18:37 UTC
[R] How to make own function load automatically on startup
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. >
Hans-Peter
2007-Oct-29 11:43 UTC
[R] How to make own function load automatically on startup
> > 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?> help("::")-- Regards, Hans-Peter [[alternative HTML version deleted]]
Jonas Malmros
2007-Oct-30 12:28 UTC
[R] How to make own function load automatically on startup
Thanks, Hans-Peter, But still, this is quite difficult to understand for non-initiated. What do expressions "exported variable" and "internal variable" mean? What is "name space"? In LAYMAN terms. Thanks in advance! On 10/29/07, Hans-Peter <gchappi at gmail.com> wrote:> > > 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? > > > help("::") > > -- > Regards, > Hans-Peter-- Jonas Malmros Stockholm University Stockholm, Sweden