I think this would be a good change. I think most users use the
'methods(class = <...>)' function to answer the question, "what
methods can I call on objects with these classes?", and in that
context I think it would be sensible for the function to accept more
than one class.

Kevin

On Wed, Oct 17, 2018 at 7:15 AM Martin Maechler
<maech...@stat.math.ethz.ch> wrote:
>
> With new "strict" settings in R-devel, the following glm() example
>
> > data(anorexia, package = "MASS")
> > fm <- glm(Postwt ~ Prewt + Treat + offset(Prewt), family = gaussian, data = 
> > anorexia)
> > methods(class = class(fm))
> Warning in grep(name, row.names(info)) :
>   argument 'pattern' has length > 1 and only the first element will be used
> Warning in gsub(name, "", row.names(info)) :
>   argument 'pattern' has length > 1 and only the first element will be used
> Warning in grep(pattern, all.names, value = TRUE) :
>   argument 'pattern' has length > 1 and only the first element will be used
> Warning in grep(pattern, all.names, value = TRUE) :
>   argument 'pattern' has length > 1 and only the first element will be used
> ...........
> ...........
> ...........
> [ca. 20 lines of warnings]
>
> and then shows the "glm" methods, but not "lm" ones.
>
> This is not a bug strictly, as  ?methods says that
>
>    class: a symbol or character string naming a class: only used if
>           ‘generic.function’ is not supplied.
>
> and so the use of
>
>            methods(class = class(<obj>))
>
> is a user error when  class(<obj>)  is of length > 1.
>
> In the case of e.g. a randomForest() result, we also get 25
> warnings, i.e. 50 lines, but then
>
> --->>>  no methods found
>
> because
>
>    > class(rf.fit)
>    [1] "randomForest.formula" "randomForest"
>
> and no methods are  defined for "randomForest.formula".
>
> ---
>
> Of course, all this works fine with S4 classes:  There the full
> inheritance is used and all methods are found.
>
> Still, would it make sense to improve the underlying .S3methods() ?
>
> I assume it will break *some* overzealous package checks out
> there when .S3methods() and hence methods() would return *more*
> in such case.
>
> Comments?
>
> --
> Martin Maechler
> ETH Zurich  and  R Core
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to