1. I'm putting together my first package that uses S4 classes and objects. I'd like to document them, but I'm not sure what the documentation should look like, and package.skeleton doesn't produce any at all for the classes or methods. Are there any good examples to follow? 2. How do I do the equivalent of debug(foo), when foo is an anonymous function being used as a method? Duncan Murdoch
I was a little stumped with documenting S4 classes too when writing the `gpclib' package. There are the promptClass() and promptMethods() which provide a bare-bones Rd file for a particular class. -roger Duncan Murdoch wrote:> 1. I'm putting together my first package that uses S4 classes and > objects. I'd like to document them, but I'm not sure what the > documentation should look like, and package.skeleton doesn't produce > any at all for the classes or methods. > > Are there any good examples to follow? > > 2. How do I do the equivalent of debug(foo), when foo is an anonymous > function being used as a method? > > Duncan Murdoch > > ______________________________________________ > R-devel@stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-devel > >
Duncan Murdoch wrote:> > 1. I'm putting together my first package that uses S4 classes and > objects. I'd like to document them, but I'm not sure what the > documentation should look like, and package.skeleton doesn't produce > any at all for the classes or methods.Hmm, sounds as if it should. Meanwhile, promptClass and promptMethods generate skeleton documentation.> > Are there any good examples to follow?The bioconductor packages (e.g, Biobase) have some examples.> > 2. How do I do the equivalent of debug(foo), when foo is an anonymous > function being used as a method?The S4-style trace() function allows you to insert debugging functions (or any expressions) into functions; it has a `signature' argument that causes the debugging to be inserted into the method with the corresponding signature. Usually either `browser' or `recover' are suitable functions to insert. My canonical piece of debugging code is along the lines of: trace("f", signature = "numeric", browser, exit = browser) If you are really attached to debug(), you can insert an extra level of function call; i.e., instead of: fNumeric <- function(x)x+1 setMethod("f", "numeric", fNumeric) and then the call to trace, do setMethod("f", "numeric", function(x)fNumeric(x)) debug(fNumeric) But trace() is more flexible, though requiring a bit more typing. John> > Duncan Murdoch > > ______________________________________________ > R-devel@stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-devel-- John M. Chambers jmc@bell-labs.com Bell Labs, Lucent Technologies office: (908)582-2681 700 Mountain Avenue, Room 2C-282 fax: (908)582-3340 Murray Hill, NJ 07974 web: http://www.cs.bell-labs.com/~jmc
My previous post should have had this subject heading - my apologies. Gordon --------------------------------------------------------------------------------------- Dr Gordon K Smyth, Senior Research Scientist, Bioinformatics, Walter and Eliza Hall Institute of Medical Research, 1G Royal Parade, Parkville, Vic 3050, Australia Tel: (03) 9345 2326, Fax (03) 9347 0852, Email: smyth@wehi.edu.au, www: http://www.statsci.org
Seemingly Similar Threads
- Re: R-devel Digest, Vol 3, Issue 23
- Rcmd check does not recognize formal generic function as code object
- Using a function from splines.c in our package
- formal methods and classes and capitalization conventions
- How do I know if the deviance of a glm fit was fixed?