Hi All, I'd like to know what is the best way to organize R code in multiple modules and files. The R code we are writing is too much for a single file. Besides, there are a lot of reusable functions we'd like to factor out. But writing a package for that is quite an over-kill and might be too inflexible. So what is the best way to organize R code into multiple files and reusable modules? Thanks, Geoffrey _______________________________________________________=0A=0A=0AThe information in this email or in any file attached hereto is=0Aintended only for the personal and confidential use of the individual=0Aor entity to which it is addressed and may contain information that is=0Aproprietary and confidential. If you are not the intended recipient of=0Athis message you are hereby notified that any review, dissemination,=0Adistribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product. Email transmission cannot be guaranteed to be secure or error-free.
You could have a master file that sources the rest: source("A.R") source("B.R") or you could save the function in a workspace and just load it back in; however, at some point I would move that all to a package. I typically will create a package for myself even if I have no intention of distributing it since it nicely puts together all the source and documentation and the checking tools are helpful to improve the QA. Its a bit of work to figure it all out the first time but once you are over that hump its worth it. On 1/2/07, Geoffrey Zhu <gzhu at peak6.com> wrote:> Hi All, > > I'd like to know what is the best way to organize R code in multiple modules> and files. The R code we are writing is too much for a single file. Besides> , there are a lot of reusable functions we'd like to factor out. But writing> a package for that is quite an over-kill and might be too inflexible. > > So what is the best way to organize R code into multiple files and reusable> modules? > > Thanks, > Geoffrey > > > > _______________________________________________________=0A> =0A> =0A> The information in this email or in any file attached hereto is=0A> intended only for the personal and confidential use of the individual=0A> or entity to which it is addressed and may contain information that is=0A> proprietary and confidential. If you are not the intended recipient of=0A> this message you are hereby notified that any review, dissemination,=0A> distribution or copying of this message is strictly prohibited. This communi> cation is for information purposes only and should not be regarded as an off> er to sell or as a solicitation of an offer to buy any financial product. Em> ail transmission cannot be guaranteed to be secure or error-free. > > ______________________________________________ > 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. >
On 1/2/2007 12:46 PM, Geoffrey Zhu wrote:> Hi All, > > I'd like to know what is the best way to organize R code in multiple modules> and files. The R code we are writing is too much for a single file. Besides> , there are a lot of reusable functions we'd like to factor out. But writing> a package for that is quite an over-kill and might be too inflexible. > > So what is the best way to organize R code into multiple files and reusable> modules?Write a package for it. It's not overkill, it's using the tools the way they were designed to be used. Not all packages need to be submitted to CRAN, you can have a package for your own use. It gives you a way to organize your code and documentation, numerous code checking tools, namespaces, all sorts of good stuff. Duncan Murdoch
Seemingly Similar Threads
- vectorizing an iterative process.
- Scope
- Difference of array and vector
- .jinit() : Cannot create Java virtual machine
- Error .jcall(mxe, "S", "fit", c("autorun", "-e", afn, "-o", dirout, : java.lang.NoSuchMethodError: density.Params.readFromArgs([Ljava/lang/String; )Ljava/lang/String;