[Rd] require is to suggests as what is to imports?

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Aug 24 22:50:38 CEST 2010


On Tue, 24 Aug 2010, Hadley Wickham wrote:

> Hi all,
>
> If a package suggests another package in its description, you can
> check it at runtime with requires.  How do you do check if a package

Well, not really as requires() can give an error, at least until 
2.12.0 is out.  So you need to wrap it in a try/tryCatch construct.

> is available without loading it, if you only want to access one
> function in the package namespace.

You could use try/tryCatch on pkg::fun (which is what you need to do 
with require).  It is difficult (and would be fragile since the 
details of metadata are definitely subject to change without notice) 
to ascertain what a namespace will contain/export without loading it.

> Thanks,
>
> Hadley
>
> -- 
> Assistant Professor / Dobelman Family Junior Chair
> Department of Statistics / Rice University
> http://had.co.nz/
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list