[R] How to load functions in R
Mihai.Mirauta at bafin.de
Mihai.Mirauta at bafin.de
Thu Sep 11 16:53:05 CEST 2008
It seems that all methods work.
Source() however loads only the last function. with save(a,b,file="path") i can save more than 1 function.
Thanks a lot,
Von: Yihui Xie [mailto:xieyihui at gmail.com]
Gesendet: Donnerstag, 11. September 2008 16:48
An: a.ramasamy at imperial.ac.uk
Cc: Mirauta, Mihai; r-help at r-project.org
Betreff: Re: [R] How to load functions in R
We may just read them in the R console instead of an external editor, and "fix()" or "edit()" them when we need to make any modifications. A trivial advantage of saving them as an image file in Windows is that you can double-click the file and R will be started with these objects loaded automatically. Anyway, to save the functions as ASCII files or even write a package are also good solutions :-)
On Thu, Sep 11, 2008 at 10:34 PM, Adaikalavan Ramasamy <a.ramasamy at imperial.ac.uk> wrote:
> I would recommend saving the functions into a separate file and then
> source() as bartjoosen suggested.
> I do not recommend using save() here because the output is
> non-readable (even when using ascii=TRUE option). Which means that you
> have to load() it, then copy-and-paste into an editor before making
> changes and then running it again in R and then save() again.
> Another better option is to consider making your own package. It may
> sound complicated but once you mastered it, it makes your functions
> more portable and encourages you to document it. Further, the function
> package.skeleton() simplifies much of it.
> Regards, Adai
> Yihui Xie wrote:
>> Hi, you may save your functions somewhere on your disk using "save()"
>> and load them next time when you want to use them. See ?save and
>> On Thu, Sep 11, 2008 at 9:30 PM, <Mihai.Mirauta at bafin.de> wrote:
>>> I am trying to use self created functions in other scripts than the
>>> one where they are stored.
>>> For the moment I am using the following structure of commands to do
>>> 1. Load the text file with the functions in the current script:
>>> 2. transform the tex in a function: f1=eval(x), f2=eval(x) if
>>> more than one function is stored in the text file 3. use the
>>> functions as normal
>>> Is there another possibility to do the same?
>>> Thank you,
>>> Mihai Mirauta
>>> [[alternative HTML version deleted]]
Yihui Xie <xieyihui at gmail.com>
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
School of Statistics, Room 1037, Mingde Main Building, Renmin University of China, Beijing, 100872, China
More information about the R-help