[Rd] Methods for objects inheriting from lme (nlme package)

Johannes Ranke joh@nne@@r@nke @end|ng |rom jrwb@de
Mon Jul 20 11:12:25 CEST 2020


Dear R developers,

One function in my mkin package [1] returns an object that is originally 
created by nlme(), but contains some additional information. Its class is 
c("mmkin.nlme", "nlme", "lme").

Now I would like to use the anova() method for lme objects for comparing such 
S3 objects. Unfortunately, anova.lme currently does not check for inheritance, 
but checks the  first element of the class attribute (as obtained by 
data.class()) against a hardcoded list of classes in order to decide if it 
will work or not.

Therefore, I created a bug report [2], containing a patch [3] for nlme that 
makes anova.lme check for inheritance.

Encouraged by a kind comment by Elin Waring in the BTS, I have now revisited 
my bug report, and discovered that the help page for data.class() claims that 
its return value (the first element of the class attribute vector) is "what is 
typically useful for method dispatching".

However, I think that this use case illustrates that it would be useful not 
only to check for the primary class, but rather for class inheritance.

Do you agree that it is preferable for the S3 method to check for inheritance 
instead of checking against a hardcoded list in this case?

Kind regards,

Johannes Ranke


[1]  https://github.com/jranke/mkin/blob/master/R/nlme.mmkin.R
[2]  https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17761
[3]  https://bugs.r-project.org/bugzilla/attachment.cgi?id=2578



More information about the R-devel mailing list