with_package | R Documentation |
with_package()
attaches a package to the search path, executes the code, then
removes the package from the search path. The package namespace is not
unloaded however. with_namespace()
does the same thing, but attaches the
package namespace to the search path, so all objects (even unexported ones) are also
available on the search path.
with_package(
package,
code,
pos = 2,
lib.loc = NULL,
character.only = TRUE,
logical.return = FALSE,
warn.conflicts = FALSE,
quietly = TRUE,
verbose = getOption("verbose")
)
local_package(
package,
pos = 2,
lib.loc = NULL,
character.only = TRUE,
logical.return = FALSE,
warn.conflicts = FALSE,
quietly = TRUE,
verbose = getOption("verbose"),
.local_envir = parent.frame()
)
with_namespace(package, code, warn.conflicts = FALSE)
local_namespace(package, .local_envir = parent.frame(), warn.conflicts = FALSE)
with_environment(
env,
code,
pos = 2L,
name = format(env),
warn.conflicts = FALSE
)
local_environment(
env,
pos = 2L,
name = format(env),
warn.conflicts = FALSE,
.local_envir = parent.frame()
)
package |
|
code |
|
pos |
the position on the search list at which to attach the
loaded namespace. Can also be the name of a position on the current
search list as given by |
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 |
quietly |
a logical. If |
verbose |
a logical. If |
.local_envir |
|
env |
|
name |
name to use for the attached database. Names starting with
|
[any]
The results of the evaluation of the code
argument.
withr
for examples
## Not run:
with_package("ggplot2", {
ggplot(mtcars) + geom_point(aes(wt, hp))
})
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.