From ripley at stats.ox.ac.uk  Sat Apr 21 16:49:35 2012
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Sat, 21 Apr 2012 15:49:35 +0100
Subject: [Rd] R CMD check -- non S3 method warning
In-Reply-To: <CAMi=pg43sztz0rX-DVpDTbv4S3WhbtvmYpe7YMWcAjGdcg9uwQ@mail.gmail.com>
References: <CAMi=pg43sztz0rX-DVpDTbv4S3WhbtvmYpe7YMWcAjGdcg9uwQ@mail.gmail.com>
Message-ID: <4F92C8FF.3040505@stats.ox.ac.uk>

On 21/04/2012 14:18, Whit Armstrong wrote:
> 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
> namespace.
>
> Is there a way of telling CMD check that the name is intentional and
> is not meant to be an S3 method?

More importantly, there is no way to tell the generic, and there is a 
"dist" class in use in the 'stats' package.

>
> 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"
>      x
> }
>
>
> with corresponding man page:
> \name{normal.dist}
> \alias{normal.dist}
> \alias{uniform.dist}
> \alias{gamma.dist}
> \alias{bernoulli.dist}
> \alias{binomial.dist}
> ...
> ...
>
> \usage{
> 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
> type'.dist.
>
> 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)?

That's a question for them, not R-devel, isn't it?

>
> Thanks,
> Whit
>
>
>
> * 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
> gamma:
>    function(x)
> gamma.dist:
>    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':
>    ?gamma.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.
> See
>    ?/home/warmstrong/dvl/R.packages/rcppbugs.Rcheck/00check.log?
> for details.
>
> warmstrong at krypton:~/dvl/R.packages$ R
>> gamma
> function (x)  .Primitive("gamma")
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] R CMD check -- non S3 method warning
Prof Brian Ripley