[R] R: R: how to split and handle a big R program into multiple files

Duncan Murdoch murdoch at stats.uwo.ca
Thu Apr 23 14:21:07 CEST 2009


On 4/23/2009 7:15 AM, mauede at alice.it wrote:
> I read the on-line documentation.
> What I am still missing is how I run my program after encapsulating it in a package.
> I will have to load the package ... just guessing

If I had a large program that I needed to run just once, e.g. an 
analysis or simulations for a paper, here's how I would organize it:

  - Identify all the general purpose functions and put them in a package.
  - The one-off parts of the code don't really belong as functions in a 
package, though there's nothing to stop you from doing that.  I'd 
probably put them into a vignette, or just write the whole paper in 
Sweave, which is almost the same thing.

If your general purpose functions do something new that would be useful 
to others, you might want to polish up the package and send it to CRAN 
(and perhaps submit it with a supporting paper to JSS).  But that's not 
necessary:  a package is a good way to organize code for your own use too.

Duncan Murdoch

> 
> Thank you
> maura
> 
> -----Messaggio originale-----
> Da: baptiste auguie [mailto:ba208 at exeter.ac.uk]
> Inviato: gio 23/04/2009 12.17
> A: mauede at alice.it
> Cc: r-help Help
> Oggetto: Re: R: [R] how to split and handle a big R program into multiple files
>  
> It is an R command (package utils), see ?package.skeleton
> 
> baptiste
> 
> On 23 Apr 2009, at 10:51, mauede at alice.it wrote:
> 
>>
>> Is that an R command ?
>> I browswd for the on-line hlp about such a command but could not  
>> find it.
>> Thank you.
>> maura
>>
>>
>> -----Messaggio originale-----
>> Da: baptiste auguie [mailto:ba208 at exeter.ac.uk]
>> Inviato: gio 23/04/2009 11.48
>> A: mauede at alice.it
>> Cc: r-help Help
>> Oggetto: Re: [R] how to split and handle a big R program into  
>> multiple files
>>
>>
>> If most of the functions are quite stable (you don't change them too
>> often), you could also consider creating a R package with
>> package.skeleton.
>>
>>
>> baptiste
>>
>>
>>
>> On 23 Apr 2009, at 10:39, jgarcia at ija.csic.es wrote:
>>
>> > source() and the use of functions
>> > ...
>> > Javier
>> > ---
>> >
>> >> I am working on a program totally written in R which is now getting
>> >> bigger
>> >> and bigger so that editling the only file that contains all the
>> >> functions
>> >> is becoming more and more unmanageable.
>> >> I wonder whether it is possible to spread the R code, making up the
>> >> same
>> >> program, in a number of smaller files and then call them all, in
>> >> the right
>> >> order, through a list of something like the C language <include>
>> >> directive.
>> >>
>> >> Any other suggestion how to organize, handle, and maintain a big R
>> >> program
>> >> is welcome.
>> >>
>> >> Thank you in advance,
>> >> Maura
>> >>
>> >>
>> >> tutti i telefonini TIM!
>> >>
>> >>
>> >>      [[alternative HTML version deleted]]
>> >>
>> >> ______________________________________________
>> >> 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.
>>
>> _____________________________
>>
>> Baptiste Auguié
>>
>> School of Physics
>> University of Exeter
>> Stocker Road,
>> Exeter, Devon,
>> EX4 4QL, UK
>>
>> Phone: +44 1392 264187
>>
>> http://newton.ex.ac.uk/research/emag
>> ______________________________
>>
>>
>>
>>
>> Alice Messenger ;-) chatti anche con gli amici di Windows Live  
>> Messenger e tutti i telefonini TIM!
> 
> er
>>
> 
> _____________________________
> 
> Baptiste Auguié
> 
> School of Physics
> University of Exeter
> Stocker Road,
> Exeter, Devon,
> EX4 4QL, UK
> 
> Phone: +44 1392 264187
> 
> http://newton.ex.ac.uk/research/emag
> ______________________________
> 
> 
> 
> 
> 
> tutti i telefonini TIM!
> 
> 
> 	[[alternative HTML version deleted]]
> 
> 
> 
> ------------------------------------------------------------------------
> 
> ______________________________________________
> 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.




More information about the R-help mailing list