Aliases: env new_environment
Keywords:
### ** Examples # env() creates a new environment that inherits from the current # environment by default env <- env(a = 1, b = "foo") env$b
[1] "foo"
identical(env_parent(env), current_env())
[1] TRUE
# Supply one unnamed argument to inherit from another environment: env <- env(base_env(), a = 1, b = "foo") identical(env_parent(env), base_env())
[1] TRUE
# Both env() and child_env() support tidy dots features: objs <- list(b = "foo", c = "bar") env <- env(a = 1, !!! objs) env$c
[1] "bar"
# You can also unquote names with the definition operator `:=` var <- "a" env <- env(!!var := "A") env$a
[1] "A"
# Use new_environment() to create containers with the empty # environment as parent: env <- new_environment() env_parent(env)
<environment: R_EmptyEnv>
# Like other new_ constructors, it takes an object rather than dots: new_environment(list(a = "foo", b = "bar"))
<environment: 0x55ccff072ab0>