Hello! I am working on a package where Enhances field seems to be a plausible option. When I add package, say coda, to this field, I get the following warning with recent R-devel: ---- * checking for working latex ... OK * using log directory '/home/ggorjan/programs/R/devel/test.Rcheck' * using R version 2.5.0 Under development (unstable) (2006-12-06 r40129) * checking for file 'test/DESCRIPTION' ... OK * this is package 'test' version '0.1' * checking package dependencies ... WARNING 'library' or 'require' calls not declared from: coda See the information on DESCRIPTION files in the chapter 'Creating R packages' of the 'Writing R Extensions' manual. ---- I have require(code) somewhere in the code. Is this OK or is R CMD check to stringent in case of enhances field - I get no warning if that package is in depends or suggests fields? After a short look into src/library/tools/R/QC.R I think that the following might be the solution. I did not do any other testing than with my package, where R CMD check (R with proposed change) passed without warnings. Index: src/library/tools/R/QC.R ==================================================================--- src/library/tools/R/QC.R (revision 40129) +++ src/library/tools/R/QC.R (working copy) @@ -3659,8 +3659,8 @@ standard_package_names <- .get_standard_package_names()$base %w/o% c("methods", "stats4") depends_suggests <- c(depends, suggests, pkg_name, contains, - standard_package_names) - imports <- c(imports, depends_suggests, enhances) + standard_package_names, enhances) + imports <- c(imports, depends_suggests) ## the first argument could be named, or could be a variable name. ## we just have a stop list here. common_names <- c("pkg", "pkgName", "package", "pos") -- Lep pozdrav / With regards, Gregor Gorjanc ---------------------------------------------------------------------- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc <at> bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europe fax: +386 (0)1 72 17 888 ---------------------------------------------------------------------- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C.
Kurt Hornik wrote:>>>>>> Gregor Gorjanc writes: > >> Hello! > >> I am working on a package where Enhances field seems to be a plausible >> option. When I add package, say coda, to this field, I get the >> following warning with recent R-devel: > >> ---- > >> * checking for working latex ... OK >> * using log directory '/home/ggorjan/programs/R/devel/test.Rcheck' >> * using R version 2.5.0 Under development (unstable) (2006-12-06 r40129) >> * checking for file 'test/DESCRIPTION' ... OK >> * this is package 'test' version '0.1' >> * checking package dependencies ... WARNING >> 'library' or 'require' calls not declared from: >> coda > >> See the information on DESCRIPTION files in the chapter 'Creating R >> packages' of the 'Writing R Extensions' manual. > > Why would you think that Enhances: is right here? > > If you use library or require on a package, you do more than enhance it, > and the package should be listed in Depends or Suggests.I might have understood Enhances field wrongly but imagine this situation. I have a package A and if I can use package B I would like to use it otherwise try with "my own" solution. I thought that Enhances fields is exactly for such situation. How should I check if package B is available? I used if(require(B)) { someSuperDuperFuncFromPkgB() } else { myOwnStuff() } But R CMD check complains. I have encountered this with R2WinBUGS. This package helps calling WinBUGS from R. It can also use OpenBUGS via BRugs, but BRugs is available only for Windows. Therefore, one can not do any QC under Linux. I thought to provide ability to call OpenBUGS via the same way WinBUGS is called and then to put BRugs in Enhances field. But R CMD check complained about use of require() for a package that is in Enhanced field. Thanks! Gregor
Gregor Gorjanc
2006-Dec-12 20:50 UTC
[Rd] Conditional suggest (was Re: Enhances, require() and quality control)
Kurt Hornik wrote:>>>>>> Gregor Gorjanc writes:...>> I might have understood Enhances field wrongly but imagine this >> situation. I have a package A and if I can use package B I would like to >> use it otherwise try with "my own" solution. I thought that Enhances >> fields is exactly for such situation. How should I check if package B is >> available? I used > >> if(require(B)) { >> someSuperDuperFuncFromPkgB() >> } else { >> myOwnStuff() >> } > >> But R CMD check complains. > >> I have encountered this with R2WinBUGS. This package helps calling >> WinBUGS from R. It can also use OpenBUGS via BRugs, but BRugs is >> available only for Windows. Therefore, one can not do any QC under >> Linux. I thought to provide ability to call OpenBUGS via the same way >> WinBUGS is called and then to put BRugs in Enhances field. But R CMD >> check complained about use of require() for a package that is in >> Enhanced field. > > This is not "enhancing" the way it is currently implemented, which is > allowing for the possibility to provide S3 or S4 methods for classes > from another package without actively suggesting it (thus enhancing > it). What you describe seems to be a need for conditionally suggesting > packages, e.g. if it is known that these are only available on certain > platforms. I don't think this is currently possible.OK. Is there some way to test which package is being used i.e. the "standard" or enhanced one? Or to paraphrase this differently. Are there any proposals how "conditional suggest" could be done? Thanks! Gregor