Dapatkan, atur, uji, dan ciptakan lingkungan.
environment(fun = NULL)
environment(fun) <- value<p></p><p>is.environment(x)</p><p>.GlobalEnv
globalenv()
.BaseNamespaceEnv</p><p>emptyenv()
baseenv()</p><p>new.env(hash = TRUE, parent = parent.frame(), size = 29L)</p><p>parent.env(env)
parent.env(env) <- value</p><p>environmentName(env)</p><p>env.profile(env)</p>
| Parameter | Deskripsi |
|---|---|
fun |
a function, a formula, or NULL, which is the default. |
value |
an environment to associate with the function |
x |
an arbitrary R object. |
hash |
a logical, if TRUE the environment will use a hash table. |
parent |
an environment to be used as the enclosure of the environment created. |
env |
an environment |
size |
an integer specifying the initial size for a hashed environment. An internal default value will be used if size is NA or zero. This argument is ignored if hash is FALSE. |
# NOT RUN {
f <- function() "top level function"
##-- all three give the same:
environment()
environment(f)
.GlobalEnv
ls(envir = environment(stats::approxfun(1:2, 1:2, method = "const")))
is.environment(.GlobalEnv) # TRUE
e1 <- new.env(parent = baseenv()) # this one has enclosure package:base.
e2 <- new.env(parent = e1)
assign("a", 3, envir = e1)
ls(e1)
ls(e2)
exists("a", envir = e2) # this succeeds by inheritance
exists("a", envir = e2, inherits = FALSE)
exists("+", envir = e2) # this succeeds by inheritance
eh <- new.env(hash = TRUE, size = NA)
with(env.profile(eh), stopifnot(size == length(counts)))
# }