library {SweaveListingUtils} | R Documentation |
library
and require
load add-on packages.
In the masked versions of package SweaveListingUtils documented here, they
also register corresponding symbols. Besides this registration, they
behave identically to the original versions of package base.
Hence much of this help is also just copied from the original help page.
library(package, help, pos = 2, lib.loc = NULL, character.only = FALSE, logical.return = FALSE, warn.conflicts = TRUE, keep.source = getOption("keep.source.pkgs"), verbose = getOption("verbose"), version, inSweave, keywordstyles, interm.keywordstyles, overwrite, intermediate) require(package, lib.loc = NULL, quietly = FALSE, warn.conflicts = TRUE, keep.source = getOption("keep.source.pkgs"), character.only = FALSE, version, save = TRUE, inSweave, keywordstyles, interm.keywordstyles, overwrite, intermediate)
package, help |
the name of a package, given as a name or
literal character string, or a character string, depending on
whether character.only is FALSE (default) or
TRUE ). |
pos |
the position on the search list at which to attach the
loaded package. Note that .First.lib may attach other
packages, and pos is computed after .First.lib
has been run. Can also be the name of a position on the current
search list as given by search() . |
lib.loc |
a character vector describing the location of R
library trees to search through, or NULL . The default value
of NULL corresponds to all libraries currently known.
Non-existent library trees are silently ignored. |
character.only |
a logical indicating whether package or
help can be assumed to be character strings. |
version |
A character string denoting a version number of the package to be loaded, for use with versioned installs: see the section later in this document. |
logical.return |
logical. If it is TRUE , FALSE or
TRUE is returned to indicate success. |
warn.conflicts |
logical. If TRUE , warnings are
printed about conflicts from attaching the new
package, unless that package contains an object
.conflicts.OK . A conflict is a function masking a function,
or a non-function masking a non-function.
|
keep.source |
logical. If TRUE , functions
‘keep their source’ including comments, see argument
keep.source to options . This applies only to
the named package, and not to any packages or name spaces which might be
loaded to satisfy dependencies or imports.
This argument does not apply to packages using lazy-loading. Whether they have kept source is determined when they are installed (and is most likely false). |
verbose |
a logical. If TRUE , additional diagnostics are
printed. |
quietly |
a logical. If TRUE , no message confirming
package loading is printed. |
save |
logical or environment. If TRUE , a call to
require from the source for a package will save the name of
the required package in the variable ".required" , allowing
function detach to warn if a required package is
detached. See section ‘Packages that require other packages’ below. |
inSweave |
shall the command show Sweave behaviour (no startup messages;
instead issuing new symbols for morekeywords tag in
language definition of R in TeX package ‘listings’)?
By default argument is taken from
getSweaveListingOption . |
keywordstyles |
character or missing or NULL ; added argument in masked
versions of library and require of package
SweaveListingUtils; if given, the keywordstyle to be
used by TeX package 'listings' for the symbols attached in this package
(to be found with ls() ). Remember that special characters like \
have to be escaped. If missing, a special strategy is used to get
sensible value (see details). |
interm.keywordstyles |
character or missing or NULL ; added argument in masked
versions of library and require of package
SweaveListingUtils; if given, the keywordstyle to be
used by TeX package 'listings' for the symbols to be found by automatically
loaded intermediate packages (mentioned in 'depends' field of the corresponding
DESCRIPTION file). This will only be used if effective argument
intermediate is TRUE . Remember that special characters like \
have to be escaped. If missing, a special strategy is used to get
sensible value (see details). |
overwrite |
logical or missing or NULL ; added argument in masked
versions of library and require of package
SweaveListingUtils; if missing, the corresponding global option is read
out by getSweaveListingOption . Let us call the corresponding
possibly imputed value effective value. If this effective value is
TRUE , before registering a new symbol for TeX package 'listings',
we first check whether this symbol had already been registered in
the original 'listings'-language definition of R in file ‘lstlang3.sty’
[which we have copied to the internal (un-exported) constant
.keywordsR ] and if so do not include the symbol once again; if the value is FALSE ,
no matter of the original language definition all symbols to be found by ls()
are registered and hence typeset in the corresponding package-keywordstyle. |
intermediate |
logical or missing or NULL ; added argument in masked
versions of library and require of package
SweaveListingUtils; if missing, the corresponding global option is read
out by getSweaveListingOption . If the effective value is
TRUE , also the symbols to be found in newly, automatically loaded
packages (loaded, because the required/"library"-ed package features them
in its corresponding Depends field in its DESCRIPTION file)
are registered for TeX package 'listings'. |
library
and require
are masked versions of the original
versions in package base. This masking is necessary to allow for
extra arguments keywordstyles
, interm.keywordstyles
,
overwrite
, intermediate
. Hence please confer
library
, require
.
If argument inSweave
is FALSE
or if argument
inSweave
is missing and the corresponding global
option getSweaveListingOption("inSweave")
is FALSE
,
then library
and require
behave exactly as the base
package versions; only if the effective argument is TRUE
,
the corresponding startup-messages are suppressed, and the TeX
code for registering all new symbols to be found with ls
as
morekeywords
for the R language definition in TeX package
‘listings’ is issued (and hence can be used in ‘.Rnw’ files.
The strategy to fill arguments keywordstyles
and
interm.keywordstyles
if missing is as follows: First we check whether
for the corresponding package, there is an enty in the global
option variable .tobeDefinedPkgs
(which is a matrix residing in the
package namespace with one column of package names and one column of
corresponding keywordstyle format strings)
and if so use its corresponding keywordstyle; else we use option
Keywordstyles
resp. interm.Keywordstyles
(which we get
by getSweaveListingOption
). New entries in the global variable
.tobeDefinedPkgs
may be appended by setToBeDefinedPkgs
.
The masked versions work as follows: first the call is written to an
object and split into a base-package-part and into the extra arguments
mentioned above. Then we call base::<fct>
where <fct>
is either
require
or library
. By noting the list of attached packages
before and after this call we also get hand on the intermediate packages,
which are automatically attached packages by dependence. After this call
we register the new symbols by corresponding calls to
lstsetLanguage
.
For use in an .Rnw
file, the call to require
or library
should be wrapped into a corresponding Sweave chunk in the form
<< /chunkname/, results=tex, echo=TRUE>>= require( ..... ) @,for example
<< distrRequire, results=tex, echo=TRUE>>= require(distr) @
as the unmasked versions.
require(survival)