This creates a new environment containing exactly the same objects, optionally with a new parent.

env_clone(env, parent = env_parent(env))

Arguments

env

An environment or an object bundling an environment, e.g. a formula, quosure or closure.

parent

The parent of the cloned environment.

Examples

env <- env(!!! mtcars) clone <- env_clone(env) identical(env, clone)
#> [1] FALSE
identical(env$cyl, clone$cyl)
#> [1] TRUE