Hi All, When collating a package - where does the file of constants go? I have an R package that defines 36 new classes and the AllClasses file is getting quite long. ?I would like to re-organize the files the following way - which is also easier for my personal mental map of what is going on. #' @includes foo1.R foo2.R setClass setGeneric setMethod(initialize) constructor function I also have a file fooC.R which defines the constants like days.in.month etc. ?So should every file be? #' @includes fooC. R foo1.R foo2.R setClass setGeneric setMethod(initialize) constructor function Thanks, Glenn
On 11/11/2015 7:16 AM, Glenn Schultz wrote:> Hi All, > When collating a package - where does the file of constants go? > > I have an R package that defines 36 new classes and the AllClasses file is getting quite long. I would like to re-organize the files the following way - which is also easier for my personal mental map of what is going on. > > #' @includes foo1.R foo2.R > setClass > setGeneric > setMethod(initialize) > constructor function > > I also have a file fooC.R which defines the constants like days.in.month etc. So should every file be > #' @includes fooC. R foo1.R foo2.R > setClass > setGeneric > setMethod(initialize) > constructor function >Scoping in R doesn't care about the order of declaration. The times when collation order matters are when you need to use one object in the package to build another one. (You should be thinking of the source files as executable scripts that create a collection of objects, not as declarations.) So just make sure that if you use object A from your package when building object B, that the source to build A is executed first. Most people do this by naming the files: they'll be executed in C collation order by default. (You can list the files in the Collate field of your DESCRIPTION file if you want a different order; see Writing R Extensions for details). Duncan Murdoch
A) Do you have problem? Have you tried it? B) There is a mailing list for this sort of question... read the Posting Guide. C) What is a constant? In R, it is just another variable. The purpose of packages is to collect variables in namespaces in memory for easy access. Which means that "include" is not necessary. --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. On November 11, 2015 7:16:44 AM PST, Glenn Schultz <glennmschultz at me.com> wrote:>Hi All, >When collating a package - where does the file of constants go? > >I have an R package that defines 36 new classes and the AllClasses file >is getting quite long. ?I would like to re-organize the files the >following way - which is also easier for my personal mental map of what >is going on. > >#' @includes foo1.R foo2.R >setClass >setGeneric >setMethod(initialize) >constructor function > >I also have a file fooC.R which defines the constants like >days.in.month etc. ?So should every file be? >#' @includes fooC. R foo1.R foo2.R >setClass >setGeneric >setMethod(initialize) >constructor function > >Thanks, >Glenn >______________________________________________ >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >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.