[Rd] how to use debug.mypkg
bcarvalh at jhsph.edu
Fri Mar 23 03:16:54 CET 2007
Great tip Seth...
thanks a bunch...
On Mar 22, 2007, at 9:54 PM, Seth Falcon wrote:
> Benilton Carvalho <bcarvalh at jhsph.edu> writes:
>> it doesn't matter where..
>> just pick one of your files and set it...
>> of course, your file should be listed in the Collate field (in case
>> you changed your mind and are now using it).
> One useful trick is to create an environment object in your package's
> namespace. It is probably best to put this early in the Collate order
> so all your code can assume it is there:
> OPTIONS <- new.env(hash=TRUE, parent=emptyenv())
> Then you could have, for example, a debug flag that gets a default
> value of FALSE, but can be interactively toggled. In your package
> code you would have:
> OPTIONS$debug <- FALSE
> Then you could either export this object from your namespace or, more
> conservatively, export a function to toggle. Then an end user (or
> developer) can do:
> R> toggleDebug()
> Obviously, for this to be useful, you need to have package code that
> checks if(OPTIONS$debug) and does something different.
> + seth
> Seth Falcon | Computational Biology | Fred Hutchinson Cancer
> Research Center
> R-devel at r-project.org mailing list
More information about the R-devel