[R-pkg-devel] using a class from a suggested package

Thierry Onkelinx th|erry@onke||nx @end|ng |rom |nbo@be
Mon Feb 7 15:55:18 CET 2022


Dear all,

My package A defines an S4 method for the "inla" S3 class. The INLA package
defines this class. That package has a huge source, making the build fail
on r-universe.dev. The solution is to not importClassesFrom(INLA, inla) but
use setOldClass("inla"). Then I can list INLA under Suggests instead of
Imports. So far so good.

My package B defines S4 objects with a superclass "maybeINLA" defined
as setClassUnion("maybeInla", c("inla", "NULL")). It also imports the
method from package A which handles the "inla" class. This is where I'm
gettin stuck.
- importClassesFrom(INLA, inla) works, but then I can't Suggests INLA.
- using setOldClass("inla") yields an R CMD check warning: "class "inla" is
defined (with package slot ‘A’) but no metadata object found to revise
superClass information---not imported?  Making a copy in package ‘B’ "
- having exportClasses(inla) in package A and importClassesFrom(A, inla) in
package B works but this displays the message "Found more than one class
"inla" in cache; using the first, from namespace 'A' Also defined by 'INLA'
".

How can I use the "inla" class in package B while Suggesting the INLA
package and not have the warnings/messages?

Best regards,

ir. Thierry Onkelinx
Statisticus / Statistician

Vlaamse Overheid / Government of Flanders
INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
FOREST
Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
thierry.onkelinx using inbo.be
Havenlaan 88 bus 73, 1000 Brussel
www.inbo.be

///////////////////////////////////////////////////////////////////////////////////////////
To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey
///////////////////////////////////////////////////////////////////////////////////////////

<https://www.inbo.be>

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list