library()
by returning a value
that indicates its success or failure, so that
require
can be used in other functions.
require(package, quietly=FALSE, warn.conflicts=TRUE, keep.source=getOption("keep.source.pkgs"), character.only=FALSE, version, save=TRUE)
character.only
is FALSE (the default), then either
type is okay, otherwise it must be a character string.
character.only
is
FALSE
(the default) then
require(mylib)
(without quotes) is equivalent to
require("mylib")
. If
character.only
is
TRUE
then the
package
argument must
be a character string or the name of a variable containing a character string.
require()
calls
library()
to load a package, but instead of failing if the package cannot be loaded,
require()
returns a logical value and all errors
appear as warnings.
This preliminary version of the function ignores most of the arguments
and so does not include some of the functionality of R's version of
require()
.
No records are kept of 'required' libraries for use by
detach
.
if (require(myPackage)) { # call functions or use data from myPackage } else warning("myPackage is not available")