\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
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{Details}\relax
The global environment \code{.GlobalEnv} is the first item on the
search path, more often known as the user's workspace.  It can also be
accessed by \code{globalenv()}.\end{Details}
\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 current evaluation environment is
returned.

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}

