place_in_env: Place variables into an environment

Description Usage Arguments Details Value See Also Examples

Description

Place the specified variables into the environment supplied.

Usage

1
place_in_env(..., envir = NULL, var_names = NULL)

Arguments

...

the variables to place into the environment (can be named or unnamed).

envir

the environment object into which to place the variables. The default is the environment of the function itself (which would not be very useful in practice but this is by design to avoid any unintended additions to an environment). So envir should usually be explicitly specified.

var_names

an optional character vector of names for the variables within the environment. See 'Details' for information about default naming.

Details

If envir is NULL, a new environment will be created with new.env and an empty parent, i.e., new.env(parent = emptyenv()).

Names for the environment variables are assigned as follows:

Value

the environment supplied, updated to include variables specified in the ellipsis argument (invisibly)

See Also

new.env, emptyenv

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
an_env <- new.env(parent = emptyenv())
place_in_env(x = 1, y = 2, envir = an_env)
# now it is possible to access these by, e.g. an_env$y etc.

# the following would all be equivalent in terms of naming, i.e. they would
# all result in the names "a" and "b" being assigned:
place_in_env("one", "two")
place_in_env(a = "one", b = "two")
place_in_env("one", "two", var_names = c("a", "b"))

# run from within a function, the following would have the effect of placing
# the variables v and w into the function's local environment:
place_in_env(v = "one", w = "two", envir = environment())

# run from within the global environment, the following would have the effect
# of placing the variables v and w into the global environment:
## Not run: place_in_env(v = "one", w = "two", envir = environment())

toniprice/jutebag documentation built on May 12, 2019, 4:39 a.m.