Description Usage Arguments Details Value See Also Examples
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.
As the original may have changed in the mean time in doubt please rely
on the original help page.
1 2 3 4 5 6 7 8 9 10 11 12 | library(package, help, pos = 2, lib.loc = NULL,
character.only = FALSE, logical.return = FALSE,
warn.conflicts = TRUE, quietly = FALSE,
keep.source = getOption("keep.source.pkgs"),
verbose = getOption("verbose"), 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, 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 |
pos |
the position on the search list at which to attach the
loaded package. Note that |
lib.loc |
a character vector describing the location of R
library trees to search through, or |
character.only |
a logical indicating whether |
logical.return |
logical. If it is |
warn.conflicts |
logical. If |
keep.source |
logical. If 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 |
quietly |
a logical. If |
save |
logical or environment. If |
inSweave |
shall the command show Sweave behaviour (no startup messages;
instead issuing new symbols for |
keywordstyles |
character or missing or |
interm.keywordstyles |
character or missing or |
overwrite |
logical or missing or |
intermediate |
logical or missing or |
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 in case of doubt
see 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
1 2 3 |
,for example
1 2 3 |
In order to unmask the original versions of library
and require
again after Sweave-ing your .Rnw
file, at the end of your .Rnw
file you should include an Sweave chunk like
1 2 3 | <<cleanup, echo=FALSE>>=
unloadNamespace("SweaveListingUtils")
@
|
or, if you want to keep the namespace of SweaveListingUtils loaded
1 2 3 | <<cleanup2, echo=FALSE>>=
SweaveListingUtils(inSweave = FALSE)
@
|
as the unmasked versions.
1 | require(survival)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.