Skip to content
Prev 9757 / 63424 Next

Documenting classes and methods: was [Rd] Re: R-devel Digest, Vol 3, Issue 23

Many thanks for your helpful comments.

To over-simplify the previous discussion a bit, you are emphasising that 
all the aliases written by promptMethods will be needed by future versions 
of the help system, so it is important that they be included in .Rd files 
documenting methods. I was saying that these aliases are very verbose.

I am not the only one having trouble with the aliases. I have looked 
through all the R packages that I know of that use S4 methods and can't 
find even one example of a documented method which preserves all the 
promptMethod style aliases. This may be partly because package authors 
aren't sure what they should be doing, but I think it has to be taken as a 
pretty strong statement from authors that the aliases don't produce a 
workable result with the online help system as it currently stands. The 
trouble I think is with the html package contents page, which very quickly 
becomes too long and cluttered to be useful if all the aliases are included.

Could we satisfy both needs, (i) to have a unique help alias associated 
with each method and (ii) to have a package contents page which is 
readable, by giving authors control over which aliases are included on the 
contents page? Could we have a new command \aliasonly{} for the .Rd files 
for aliases which are to be available to the help system but not listed on 
the contents page? Authors could use \alias{} for aliases which are to be 
listed and \aliasonly{} for aliases which aren't.

It might also be helpful to have an optional argument, as in 
\alias[optional.text]{}, to choose the text which is listed on the package 
contents page.

Some other comments on generic functions are interpolated below.

Regards
Gordon
At 12:45 AM 27/05/2003, John Chambers wrote:
The need for extra arguments seems to increase with the complexity of the 
task which the generic function does. In R base most use of generic 
functions are for language-type functions like 'print' or 'summary', 
although there are also data analysis functions like 'anova', 'residuals' 
and 'coefficients'. In Bioconductor we are tying to use S4 generic 
functions to undertake some quite complex data analysis talks, for example 
the 'normalization' of a mult-array microarray experiment. Normalization 
means to adjust the data for unwanted systematic trends due to 
technological sources other than the genes and the treatments of interest. 
The generic function 'normalize' encapsulates a single unifying concept, 
but the implementation may differ considerably depending on the type of 
microarrays being used and the factors will seem important to adjust for.

We can and probably should consider using parameter-setting functions. But 
if we end up with a separate parameter-setting function for every class, 
and most users need to read the documentation for these functions, then we 
haven't really achieved a simplification.

Another consideration which seems to increase the importance of the methods 
relative to the generic function itself is the modular package style of 
development being used in R. If I am the first author to use the function 
name 'normalize', do I have the right to specify all the arguments I need 
for this function as part of the generic definition, or should I minimize 
the specified arguments to give other authors as much flexibility as possible?

One example of document which I have been using as a model is the 
documentation in R base for the S3 generic function 'residuals'. The 
?residuals document explains the concept in generic terms and limits the 
argument list to 'object' and '...'. One can then read the separate 
method-documents ?residuals.lm or ?residuals.glm for other arguments. I 
would be happy if we could do similar with S4 functions and methods.