env_unbind() is the complement of env_bind(). Like env_has(), it ignores the parent environments of env by default. Set inherit to TRUE to track down bindings in parent environments.

env_unbind(env = caller_env(), nms, inherit = FALSE)



An environment.


A character vector containing the names of the bindings to remove.


Whether to look for bindings in the parent environments.


The input object env with its associated environment modified in place, invisibly.


env <- env(foo = 1, bar = 2) env_has(env, c("foo", "bar"))
#> foo bar #> TRUE TRUE
# Remove bindings with `env_unbind()` env_unbind(env, c("foo", "bar")) env_has(env, c("foo", "bar"))
#> foo bar #> FALSE FALSE
# With inherit = TRUE, it removes bindings in parent environments # as well: parent <- env(empty_env(), foo = 1, bar = 2) env <- env(parent, foo = "b") env_unbind(env, "foo", inherit = TRUE) env_has(env, c("foo", "bar"))
#> foo bar #> FALSE FALSE
env_has(env, c("foo", "bar"), inherit = TRUE)
#> foo bar #> TRUE TRUE