Dear David,

A follow-up if you don't mind: one slot of my actual S4 object contains either 
NULL or a grid::frameGrob object. As you may know, frameGrob objects inherit 
from multiple S3 classes: "frame" "gTree" "grob"  "gDesc".

Based upon my understanding of the documentation, I need to define my S4 class 
as follows using a setOldClass call for the S3 classes that are used in the 
setClassUnion call.

----
  setOldClass(c('frame','gTree','grob','gDesc'))
  setClassUnion('myFrame', c('frame','gTree','grob','gDesc','NULL'))
  
  
  setClass('myClass',
    where = .GlobalEnv, 
    slots = c(
      grid.frame = 'myFrame',
    ),
    prototype = list(
      grid.frame = NULL,
    )
  )
----

This causes `R CMD check` to complain about "frame" "gTree" "grob"  "gDesc"
* checking for missing documentation entries ... WARNING
Undocumented S4 classes:
  "frame" "gTree" "grob"  "gDesc"
All user-level objects in a package (including S4 classes and methods)
should have documentation entries.

Including \alias{frame-class}, \alias{grob-class}, \alias{gTree-class}, 
\alias{gDesc-class} in my S4 class .Rd files prevents the WARNING to be 
reported, but this does not feel right, since these are classes from the grid 
package. Any suggestions?

Sebastien


-----------------------

From: David Kepplinger <david.kepplin...@gmail.com>
Sent: Tuesday, February 9, 2021 19:11
To: Sebastien Bihorel <sebastien.biho...@cognigencorp.com>
Cc: r-package-devel@r-project.org <r-package-devel@r-project.org>
Subject: Re: [R-pkg-devel] How to get rid of R CMD check warning/note for new 
S4 classes 
 
Dear Sabastien,

Your second approach is correct, but as the warning suggests, you have to 
document the S4 class "character or NULL". The documentation at 
https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Documenting-S4-classes-and-methods
 should get you started.

Best,
David

On Tue, Feb 9, 2021 at 6:54 PM Sebastien Bihorel 
<sebastien.biho...@cognigencorp.com> wrote:
Hi 

I posted the following message on Jan 2nd and got no response... Assuming that 
my timing was off (everybody was probably still on vacation or recovering from 
New Year's celebration), I am taking the liberty to post it again, hoping that 
I'll reach a larger audience today.

------

I am creating a few S4 classes for a package. These classes include slots set 
to classes obtained using setClassUnion (some common across the new S4 
classes). The code is functional but `R CMD check` keeps on reporting notes or 
warnings whatever I try. I am pulling my hair on this one and would really 
appreciate some insight on what I am doing wrong. 


Below are some simplified versions of a real function, which each gives 
different note/warning:

* Option 1 returns a note

createyNewClass <- function(){
  setClassUnion("character or NULL",c("character","NULL"),where = .GlobalEnv)
  setClass('newS4Classe',
    where = .GlobalEnv, 
    slots = c(type = 'character or NULL'),
    prototype = list(type = NULL)
  )
}

R CMD check
...
* checking whether the namespace can be loaded with stated dependencies ... NOTE
Warning: class "NULL" is defined (with package slot "methods") but no metadata 
object found to revise superClass information---not exported?  Making a copy in 
package ".GlobalEnv"
Warning: class "character" is defined (with package slot "methods") but no 
metadata object found to revise superClass information---not exported?  Making 
a copy in package ".GlobalEnv"
...

* Option 2: returns a WARNING

createyNewClass <- function(){
  setClassUnion("character or NULL",c("character","NULL"))
  setClass('newS4Classe',
    slots = c(type = 'character or NULL'),
    prototype = list(type = NULL)
  )
}

R CMD check:
...
* checking for missing documentation entries ... WARNING 
Undocumented S4 classes: 
   "character or numeric"
All user-level objects in a package (including S4 classes and methods) 
should have documentation entries.
...

Bit of information: I am running the R CMD check with R 3.6.1 (sorry, I cannot 
update on my corporate machine :( )

Thanks in advance for your help
______________________________________________
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


-- 
David Kepplinger, PhD
https://www.dkepplinger.org
______________________________________________
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

Reply via email to