From tlumley at u.washington.edu  Fri Jan 15 17:15:59 2010
From: tlumley at u.washington.edu (Thomas Lumley)
Date: Fri, 15 Jan 2010 08:15:59 -0800 (PST)
Subject: [Rd] optional package dependency
In-Reply-To: <4B50881B.1070106@userprimary.net>
Message-ID: <alpine.LRH.2.01.1001150815590.13188@hymn34.u.washington.edu>

On Fri, 15 Jan 2010, Seth Falcon wrote:


> There is a real need (of some kind) here.  Not all packages work on all
> platforms.  For example, the multicore package provides a mechanism for
> running parallel computations on a multi-cpu box, but it is not
> available on Windows.  A package that _is_ available on all platforms
> should be able to optionally make use of multicore on non-Windows.  I
> don't think there is a way to do that now and pass check without
> resorting to "tricks" as above.  These tricks are bad as they make it
> harder to programmatically determine the true "suggests".
>
> And NAMESPACE brings up another issue in that being able to do
> conditional imports would be very useful for these cases, otherwise you
> simply can't make proper use of name spaces for any optional functionality.
>
> I'm willing to help work on and test a solution if we can arrive at some
> consensus as to what the solution looks like.
>

Seth,

In the case of multicore it seems to work to put it in 'Suggests' and to use require() to load it. That's what I did with the survey package, and it didn't cause problems on CRAN.  I didn't run CMD check on Windows myself, only on Mac and Linux.

A more difficult issue is providing methods for a generic in another package that might not be available.  I wanted to provide methods on survey objects for generics in odfWeave, and I couldn't find out how to do that without making it required.   I ended up creating a new odfWeave.survey package that depends on odfWeave and survey, but this seems like the sort of thing that should be able to be done with Enhances or Suggests.

     -thomas


Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle



[Rd] optional package dependency
Thomas Lumley