[R] R CMD CHECK and require() / library() methods

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Apr 25 17:03:07 CEST 2007


On Wed, 25 Apr 2007, Crispin Miller wrote:

> Hi,
>
> I have a piece of code that decides at runtime whether to load a data
> package (and which package to load).
> This is then done with a call to:
>
> library(x)
>
> (where x is a character variable containing the package name).
>
> This causes R CMD check to throw out a warning:
> 'library' or 'required' calls not declared from:
> x

Which version of R is this?  All I can find say 'require'.

>
> Does anyone have any suggestions as to a fix or workaround for this?

That call should be

library(x, character.only=TRUE)

and that will in R 2.5.0 stop the warning AFAIK.

-- 
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-help mailing list