[Rd] R CMD check -- non S3 method warning

Whit Armstrong armstrong.whit at gmail.com
Sat Apr 21 15:18:03 CEST 2012

I'm trying to R CMD check a package, and I'm getting the 'checking S3
generic/method consistency' warning.

I have written a function 'gamma.dist' which is _not_ an S3 method,
but happens to collide with the 'gamma' function from the R::base

Is there a way of telling CMD check that the name is intentional and
is not meant to be an S3 method?

My function is defined as follows:

gamma.dist <- function(x,alpha,beta,observed=FALSE) {
    attr(x,"distributed") <- "gamma"
    attr(x,"alpha") <- substitute(alpha)
    attr(x,"beta") <- substitute(beta)
    attr(x,"observed") <- observed
    attr(x,"env") <- new.env()
    class(x) <- "mcmc.object"

with corresponding man page:

normal.dist(x, mu, tau, observed = FALSE)
uniform.dist(x, lower, upper, observed = FALSE)
gamma.dist(x, alpha, beta, observed = FALSE)
bernoulli.dist(x, p, observed = FALSE)
binomial.dist(x, n, p, observed = FALSE)

I am reluctant to change the name of the function b/c all my
distribution methods use the same convention of 'distribution

Do CRAN maintainers view this warning as a blocker for the package
(full make check output below, which includes a few additional
warnings I'm in the process of fixing)?


* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* building ‘rcppbugs_0.0.1.tar.gz’

* using log directory ‘/home/warmstrong/dvl/R.packages/rcppbugs.Rcheck’
* using R version 2.15.0 (2012-03-30)
* using platform: x86_64-pc-linux-gnu (64-bit)
* using session charset: UTF-8
* checking for file ‘rcppbugs/DESCRIPTION’ ... OK
* this is package ‘rcppbugs’ version ‘0.0.1’
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking if there is a namespace ... OK
* checking for executable files ... OK
* checking whether package ‘rcppbugs’ can be installed ... OK
* checking installed package size ... NOTE
  installed size is  8.4Mb
  sub-directories of 1Mb or more:
    libs   8.1Mb
* checking package directory ... OK
* checking for portable file names ... OK
* checking for sufficient/correct file permissions ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking R files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* checking whether the package can be loaded ... OK
* checking whether the package can be loaded with stated dependencies ... OK
* checking whether the package can be unloaded cleanly ... OK
* checking whether the namespace can be loaded with stated dependencies ... OK
* checking whether the namespace can be unloaded cleanly ... OK
* checking for unstated dependencies in R code ... OK
* checking S3 generic/method consistency ... WARNING
  function(x, alpha, beta, observed)

See section ‘Generic functions and methods’ of the ‘Writing R
Extensions’ manual.
* checking replacement functions ... OK
* checking foreign function calls ... OK
* checking R code for possible problems ... OK
* checking Rd files ... OK
* checking Rd metadata ... OK
* checking Rd cross-references ... OK
* checking for missing documentation entries ... OK
* checking for code/documentation mismatches ... OK
* checking Rd \usage sections ... NOTE
S3 methods shown with full name in documentation object 'normal.dist':

The \usage entries for S3 methods should use the \method markup and
not their full name.
See the chapter ‘Writing R documentation files’ in the ‘Writing R
Extensions’ manual.
* checking Rd contents ... OK
* checking for unstated dependencies in examples ... OK
* checking line endings in C/C++/Fortran sources/headers ... OK
* checking line endings in Makefiles ... OK
* checking for portable compilation flags in Makevars ... WARNING
Non-portable flags in variable ‘PKG_CXXFLAGS’:
  -Wall -std=c++0x
* checking for portable use of $(BLAS_LIBS) and $(LAPACK_LIBS) ... OK
* checking compiled code ... OK
* checking examples ... OK
* checking PDF version of manual ... OK

WARNING: There were 2 warnings.
NOTE: There were 2 notes.
for details.

warmstrong at krypton:~/dvl/R.packages$ R
> gamma
function (x)  .Primitive("gamma")

More information about the R-devel mailing list