View source: R/utils_environments_namespaces.R
| assign_in_ns | R Documentation |
Unlocks and relocks namespaces and bindings as needed
assign_in_ns(
x,
nm = rlang::expr_deparse(rlang::enexpr(x)),
ns_env = rlang::ns_env(pkg_name())
)
x |
|
nm |
|
ns_env |
|
x the object
Other namespaces:
assign_global(),
get_from_ns(),
get_global(),
pkg_ns(),
unload_namespaces()
(function(x = mtcars) {
y <- dplyr::mutate(x, cylinders = cyl)
assign_in_ns(nm = "y", ns_env = "UU")
})()
uu <- rlang::ns_env("UU")
exists("y", uu)
assign_in_ns(mtcars, ns_env = "UU")
exists("mtcars", uu)
assign_in_ns(mtcars, "cars_copy", ns_env = "UU")
exists("cars_copy", uu)
rlang::env_unlock(uu)
rm(list = c("y", "mtcars", "cars_copy"), envir = uu)
rlang::env_lock(uu)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.