[R] conditional import in NAMESPACE

Douglas Bates bates at stat.wisc.edu
Thu Apr 15 03:24:25 CEST 2004

"Liaw, Andy" <andy_liaw at merck.com> writes:

> Can some one tell me if it's possible to have conditional importFrom() in
> the package NAMESPACE file?  Basically I'd like to know if it's possible to
> make the NAMESPACE file compatible with R 1.9.0 and those 1.8.1 and earlier.
> The problem is that I want to import cmdscale(), which is in `mva' prior to
> 1.9.0 but in `stats' post 1.9.0.

Well, we've got good news and bad news.  The good news is that there
are facilities for conditionals in the NAMESPACE file.  The bad news
is that they were introduced in 1.9.0 so you can't use them for the
purpose you have in mind.

The way many of us have approached this is to freeze a version of the
package that works for R-1.8.1 and add  R(<= 1.8.1) to Depends: in the

Then bump the version number, switch to importFrom(stats, ...) in the
NAMESPACE and add R(>= 1.9.0) to the Depends: line.

More information about the R-help mailing list