From m@ech|er @end|ng |rom @t@t@m@th@ethz@ch  Thu Jul  1 08:16:46 2021
From: m@ech|er @end|ng |rom @t@t@m@th@ethz@ch (Martin Maechler)
Date: Thu, 1 Jul 2021 08:16:46 +0200
Subject: [Rd] undefined subclass warning
In-Reply-To: <d8920721-4a4d-820e-ab1c-55b693b15496@gmail.com>
References: <d8920721-4a4d-820e-ab1c-55b693b15496@gmail.com>
Message-ID: <24797.24014.946818.673060@stat.math.ethz.ch>

>>>>> Ben Bolker 
>>>>>     on Wed, 30 Jun 2021 20:23:27 -0400 writes:

    >    A colleague recently submitted a paper to JSS and was
    > advised to address the following warning which occurs when
    > their package
    > (https://CRAN.R-project.org/package=pcoxtime) is loaded:

    > Warning message: In .recacheSubclasses(def at className, def,
    > env) : undefined subclass "numericVector" of class
    > "Mnumeric"; definition not updated

    > After much digging I *think* I've concluded that this
    > comes from the following import chain:

    > pcoxtime -> riskRegression -> rms -> quantreg ->
    > MatrixModels

    >    that is, loading any of these packages throws the
    > warning.  MatrixModels Imports: *only* {stats, methods,
    > Matrix} and loading these by themselves is warning-less.

    >     I assume there is some mismatch/incompatibility
    > between MatrixModels (which was last updated 2021-03-01)
    > and Matrix (2021-05-24), which has this NEWS item in the
    > most release 1.3-3
    > <https://cran.r-project.org/web/packages/Matrix/news.html>:

    > * removed the nowhere used (and unexported but still
    > active) class union "Mnumeric" which actually trickled
    > into many base classes properties.  Notably would it break
    > validity of factor with a proposed change in validity
    > checking, as factors were also "Mnumeric" but did not
    > fulfill its validity method. Similarly removed (disabled)
    > unused class union "numericVector".

    >     It seems that REINSTALLING the package from source
    > solves the problem, which is nice, but I don't fully
    > understand why; I guess ????  there are class structures
    > that are evaluated at install time and stored in the
    > package environment ...

    >    Any more explanations would be welcome.
    >    cheers Ben

Yes, Ben,
you are right on spot and very close with your final guess.

Installation and even building of packages using S4 classes (their own *or* of
other packages where they import from) does store the class
definitions already in the binary "dump" of all the R code.

So yes, Matrix cleanup (dropping unused classes actually
helping/improving the class hiearchy by making it slightly
simpler) does need to re-installation of direct Matrix
dependencies in order to avoid the above warning --- which
otherwise has zero consequences.

So the referees of your colleague's paper / package should really learn
that they are wrong in their requirement of getting rid of that
warning.

and as you've suggested in another thread, I should alleviate
the problem by uploading a new version of 'MatrixModels' models
to CRAN {solving another small unrelated buglet} so the warnings
will go away for everyone who updates their installed packages.

Martin



[Rd] undefined subclass warning
Martin Maechler