Rev 68948 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/base/man/as.environment.Rd% Part of the R package, https://www.R-project.org% Copyright 1995-2013 R Core Team% Distributed under GPL 2 or later\name{as.environment}\alias{as.environment}\title{ Coerce to an Environment Object }\description{A generic function coercing an \R object to an\code{\link{environment}}. A number or a character string isconverted to the corresponding environment on the search path.}\usage{as.environment(x)}\arguments{\item{x}{an \R object to convert. If it is already anenvironment, just return it. If it is a positive number, return theenvironment corresponding to that position on the search list. If itis \code{-1}, the environment it is called from. Ifit is a character string, match the string to the names on thesearch list.If it is a list, the equivalent of \code{\link{list2env}(x,parent = emptyenv())} is returned.If \code{\link{is.object}(x)} is true and it has a \code{\link{class}}for which an \code{as.environment} method is found, that is used.}}\value{The corresponding environment object.}\details{This is a \link{primitive} generic function: you can write methods tohandle specific classes of objects, see \link{InternalMethods}.}\author{ John Chambers }\seealso{\code{\link{environment}} for creation and manipulation,\code{\link{search}};\code{\link{list2env}}.}\examples{as.environment(1) ## the global environmentidentical(globalenv(), as.environment(1)) ## is TRUEtry( ## <<- stats need not be attachedas.environment("package:stats"))ee <- as.environment(list(a = "A", b = pi, ch = letters[1:8]))ls(ee) # names of objects in eeutils::ls.str(ee)}\keyword{data}\keyword{environment}