
Last chance! 50% off unlimited learning
Sale ends in
environment
. A number or a character string is
converted to the corresponding environment on the search path.
as.environment(x)
-1
, the environment it is called from. If
it is a character string, match the string to the names on the
search list. If it is a list, the equivalent of list2env(x,
parent = emptyenv())
is returned.
If is.object(x)
is true and it has a class
for which an as.environment
method is found, that is used.
environment
for creation and manipulation,
search
; list2env
.
as.environment(1) ## the global environment
identical(globalenv(), as.environment(1)) ## is TRUE
try( ## <<- stats need not be attached
as.environment("package:stats"))
ee <- as.environment(list(a = "A", b = pi, ch = letters[1:8]))
ls(ee) # names of objects in ee
utils::ls.str(ee)
Run the code above in your browser using DataLab