[Rd] Clarification on generic functions and methods

Doran, Harold HDoran at air.org
Wed Nov 11 22:06:18 CET 2009


Hi Ken:

Well, I'm quite pleased with a solution I found. The t.test method and its .Rd file showed me that I can export only the generic method, use \alias{jml2.default} and \alias{jml2.formula} in the .Rd file for jml2, and then use \method{jml2}{default}{args} and \method{jml2}{formula}{args}.

Using this, I was able to build the package in both windows and Ubuntu without error.

> -----Original Message-----
> From: r-devel-bounces at r-project.org 
> [mailto:r-devel-bounces at r-project.org] On Behalf Of Ken Knoblauch
> Sent: Wednesday, November 11, 2009 3:58 PM
> To: r-devel at stat.math.ethz.ch
> Subject: Re: [Rd] Clarification on generic functions and methods
> 
> Doran, Harold <HDoran <at> air.org> writes:
> > 
> > Thank you, Henrik. This actually doesn't work when I build the 
> > package,
> which may only require a slight
> > modification to what I'm doing now. First, I create a NAMESPACE as:
> > 
> > ### NAMESPACE FILE CONTENTS
> > export(jml2)
> > S3method(jml2, fit)
> > S3method(jml2, default)
> > S3method(jml2, formula)
> > S3method(print, jml)
> > S3method(summary, jml)
> > S3method(print, summary.jml)
> > 
> > So, only the generic function (jml) is exported. 
> > 
> > Now, I do as you suggest below for the generic function, 
> but keep all 
> > others
> as they were previously. That
> > creates a situation where jml.formula, jml.default, and jml have 
> > different
>  arguments.
> > 
> > Now, in the .Rd file for the jml function I want the user 
> to see the 
> > usage for
> the jml.formula method, which
> > obviously has more args than "...". So, the .Rd file is 
> structured as
>  (for testing purposes only):
> 
> How about if you document the default method as well as the 
> generic method in your man page.  See ?lag for an example, 
> and I've come across several others recently.
> 
> HTH,
> 
> Ken
> 
> --
> Ken Knoblauch
> Inserm U846
> Stem-cell and Brain Research Institute
> Department of Integrative Neurosciences
> 18 avenue du Doyen Lépine
> 69500 Bron
> France
> tel: +33 (0)4 72 91 34 77
> fax: +33 (0)4 72 91 34 61
> portable: +33 (0)6 84 10 64 10
> http://www.sbri.fr/members/kenneth-knoblauch.html
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 


More information about the R-devel mailing list