Hi,

I have asked this question before, but the solution I ended up with (see 
below) creates a note when running R CMD check. So I am trying again...

I am developing a package B that, among other things, also offers some 
extra S3-methods for functions in package A if the user has installed A. 
I do not want to list A under Depends of B, as the dependency list of A 
is rather long, and most potential users of B will not be interested in 
package A and what it depends on. Unfortunately I struggle with doing 
this right. After asking on the list some time ago, I have listed A 
under Suggests, and have a .onLoad function in B with
if (require(A)) registerS3methods(newMethodsMatrix, package = A, env = 
environment(B))
But starting with R 2.13 or R 2.14, R CMD check creates a note:
"Package startup functions should not change the search path.
See section 'Good practice' in ?.onAttach."
I have understood that packages with notes can be uploaded to CRAN, but 
that they tend to create extra work for the maintainers and hence I am 
trying to find another solution.

So far I have tried:
List A under Suggest of B, with a conditional import in NAMESPACE.
If I build a Windows-binary from this when A is installed, this package 
can be installed but not loaded on computers where A is not installed.

List A under Enhances of B.
This seems to be the right thing, as the R extensions manual says: "the 
'Enhances' field lists packages "enhanced" by the package at hand, e.g., 
by providing methods for classes from these packages".
However, although it seems I can install and load package B when I 
conditionally import package A in the NAMESPACE, R CMD check stops with 
the error: Namespace dependency not required: A
If I remove the import, R CMD check is happier, but I cannot load the 
package after installing.

I have read about the use of "Suggest", "Enhances" etc in "Writing R 
Extensions", but could not figure out the right way to do this. I am 
sure there is something I am missing here.

If anyone wants to check possible solutions, package A is "intamap", 
available from CRAN, whereas B is "rtop", available from Rforge: 
**|install.packages("rtop", repos="http://R-Forge.R-project.org")|**

Thanks,
Jon

-- 
Jon Olav Skøien
Joint Research Centre - European Commission
Institute for Environment and Sustainability (IES)
Land Resource Management Unit

Via Fermi 2749, TP 440,  I-21027 Ispra (VA), ITALY

jon.skoien@jrc.ec.europa.eu
Tel:  +39 0332 789206

Disclaimer: Views expressed in this email are those of the individual and do not necessarily represent official views of the European Commission.



	[[alternative HTML version deleted]]

