\HeaderA{pos.to.env}{Convert Positions in the Search Path to Environments}{pos.to.env}
\keyword{utilities}{pos.to.env}
\begin{Description}\relax
Returns the environment at a specified position in the search path.
\end{Description}
\begin{Usage}
\begin{verbatim}pos.to.env(x)\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] an integer between 1 and \code{length(search())}, the length
of the search path.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Several \R{} functions for manipulating objects in environments (such as
\code{\LinkA{get}{get}} and \code{\LinkA{ls}{ls}}) allow specifying environments
via corresponding positions in the search path.  \code{pos.to.env} is
a convenience function for programmers which converts these positions
to corresponding environments; users will typically have no need for
it.  It is \LinkA{primitive}{primitive}.
\end{Details}
\begin{Examples}
\begin{ExampleCode}
pos.to.env(1) # R_GlobalEnv
# the next returns the base environment
pos.to.env(length(search()))
\end{ExampleCode}
\end{Examples}

