[R-pkg-devel] How to get rid of R CMD check warning/note for new S4 classes

Sebastien Bihorel Seb@@t|en@B|hore| @end|ng |rom cogn|gencorp@com
Wed Feb 10 00:53:43 CET 2021


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


More information about the R-package-devel mailing list