Examples for 'rlang::as_environment'


Coerce to an environment

Aliases: as_environment

Keywords:

### ** Examples

# Coerce a named vector to an environment:
env <- as_environment(mtcars)

# By default it gets the empty environment as parent:
identical(env_parent(env), empty_env())
[1] TRUE
# With strings it is a handy shortcut for pkg_env():
as_environment("base")
<environment: base>
as_environment("rlang")
<environment: package:rlang>
attr(,"name")
[1] "package:rlang"
attr(,"path")
[1] "/data/rcloud/library/4.2/rlang"
# With NULL it returns the empty environment:
as_environment(NULL)
<environment: R_EmptyEnv>

[Package rlang version 1.1.4 Index]