\Header{environment}{Environment Access}
\alias{.GlobalEnv}{environment}
\alias{environment<\Rdash}{environment}
\alias{globalenv}{environment}
\alias{is.environment}{environment}
\alias{new.env}{environment}
\keyword{data}{environment}
\keyword{programming}{environment}
\begin{Description}\relax
Get, set, test for and create environments.\end{Description}
\begin{Usage}
\begin{verbatim}
environment(fun = NULL)
environment(fun) <- value
is.environment(obj)
.GlobalEnv
new.env()
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{fun}] a \code{\Link{function}}, a \code{\Link{formula}}, or
\code{NULL}, which is the default.
\item[\code{value}] 
\item[\code{obj}] an arbitrary \R{} object.
\end{ldescription}
\end{Arguments}
\begin{Value}
If \code{fun} is a function or a formula then \code{environment(fun)}
returns the environment associated with that function or formula.
If \code{fun} is \code{NULL} then the global environment,
\code{.GlobalEnv}, is returned.  This variable is currently defined
as \code{globalenv()}.

The assignment form sets the environment of the function or formula
\code{fun} to the \code{value} given.

\code{is.environment(obj)} returns \code{TRUE} iff \code{obj} is an
\code{environment}.

\code{new.env} returns a new (empty) environment enclosed in the
parent's environment.\end{Value}
\begin{SeeAlso}\relax
The \code{envir} argument of \code{\Link{eval}}.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
##-- all three give the same:
environment()
environment(environment)
.GlobalEnv

ls(envir=environment(approxfun(1:2,1:2, method="const")))

is.environment(.GlobalEnv)# TRUE
\end{ExampleCode}
\end{Examples}

