[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
Sun Jan 3 03:29:16 CET 2021


Hi 

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.
...

Thanks


More information about the R-package-devel mailing list