[Rd] Query about .check_packages_used_in_examples

Berwin A Turlach berwin at maths.uwa.edu.au
Mon Oct 11 00:06:46 CEST 2010

G'day all,

looking at
I noticed that r-prerel-* and r-devel-* issue notes.  Apparently, now
examples are more thoroughly checked by R CMD check and the note
pointed out that a package used in the examples was not declared.  This
was easily fixed by adding 'Suggests: lattice' to the DESCRIPTION file
(now this change has to migrate through R-forge to CRAN).

But then I noticed that for another package I have on R-forge a similar
note is issued:
O.k., R-forge is using R-devel, so I installed R 2.12.0 RC (2010-10-10
r53273) on my machine to check, same note is issued.

The note issued by R CMD check says:
	* checking for unstated dependencies in examples ... NOTE
	'library' or 'require' call not declared from: ks
which is a bit surprising.  

There are three .Rd files that have a library(ks) in them and ks is
listed in the Imports: of the description file.

This seems to be completely in line with the documentation in "Writing
R extensions":

	Packages whose name space only is needed to load the package
	using @code{library(@var{pkgname})} must be listed in the
	@samp{Imports} field and not in the @samp{Depends} field.

that's why ks is listed in depends

	All packages that are needed to successfully run @code{R CMD
	check} on the package must be listed in one of @samp{Depends}
	or @samp{Suggests} or @samp{Imports}. [...]

which seems to be adhered to, since ks is in the depends.

But upon digging into .check_packages_used_in_examples in QC.R in
package tools, I have the impression that packages loaded in examples
via library() or require() are only checked against packages listed in
Suggests, Enhances and Depends, the package's own name and the standard
packages, but not against those listed in Imports.  Thus, I believe
there is some disconnect between documentation and behaviour at the

In this particular case, possible solutions would be to list ks in
both, Imports and Suggests, or, to have only one entry, to move it to

But I believe the cleaner solution would be that
.check_packages_used_in_examples includes the packages listed in
Imports when checking whether all packages used in library() or
require() commands in examples are declared.



More information about the R-devel mailing list