[R] conditional import in NAMESPACE

Liaw, Andy andy_liaw at merck.com
Thu Apr 15 03:39:07 CEST 2004


> From: Douglas Bates [mailto:bates at bates4.stat.wisc.edu] On 
> 
> "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
> DESCRIPTION file.
> 
> Then bump the version number, switch to importFrom(stats, ...) in the
> NAMESPACE and add R(>= 1.9.0) to the Depends: line.

Thanks very much, Doug.  I suppose one ugly way of getting around this is
not to import cmdscale in NAMESPACE, but to check for R version and do the
appropriate require() inside the function that needs cmdscale().  Or is that
really too ugly?

Best,
Andy




More information about the R-help mailing list