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

David Kepplinger d@v|d@kepp||nger @end|ng |rom gm@||@com
Wed Feb 10 01:11:41 CET 2021


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.Bihorel using 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 using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>


-- 
David Kepplinger, PhD
https://www.dkepplinger.org

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list