\HeaderA{getFromNamespace}{Utility functions for Developing Namespaces}{getFromNamespace}
\aliasA{assignInNamespace}{getFromNamespace}{assignInNamespace}
\aliasA{fixInNamespace}{getFromNamespace}{fixInNamespace}
\keyword{data}{getFromNamespace}
\begin{Description}\relax
Utility functions to access and replace the non-exported functions in
a name space, for use in developing packages with name spaces.
\end{Description}
\begin{Usage}
\begin{verbatim}
getFromNamespace(x, ns, pos = -1, envir = as.environment(pos))

assignInNamespace(x, value, ns, pos = -1,
                  envir = as.environment(pos))

fixInNamespace(x, ns, pos = -1, envir = as.environment(pos), ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] an object name (given as a character string).
\item[\code{value}] an \R{} object.
\item[\code{ns}] a name space, or character string giving the name space.
\item[\code{pos}] where to look for the object: see \code{\LinkA{get}{get}}.
\item[\code{envir}] an alternative way to specify an environment to look in.
\item[\code{...}] arguments to pass to the editor: see \code{\LinkA{edit}{edit}}.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The name space can be specified in several ways.  Using, for example,
\code{ns = "stats"} is the most direct, but a loaded package with a
name space can be specified via any of the methods used for
\code{\LinkA{get}{get}}: \code{ns} can also be the environment printed as
\code{<namespace:foo>}.

\code{getFromNamespace} is similar to (but predates) the
\code{\LinkA{:::}{:::}} operator, but is more flexible in how the name space
is specified.

\code{fixInNamespace} invokes \code{\LinkA{edit}{edit}} on the object named
\code{x} and assigns the revised object in place of the original
object.  For compatibility with \code{fix}, \code{x} can be unquoted.
\end{Details}
\begin{Value}
\code{getFromNamespace} returns the object found (or gives an error).

\code{assignInNamespace} and \code{fixInNamespace} are invoked for
their side effect of changing the object in the name space.
\end{Value}
\begin{Note}\relax
\code{assignInNamespace} and \code{fixInNamespace} change the copy in
the name space, but not any copies already exported from the name space,
in particular an object of that name in the package (if already
attached) and any copies already imported into other name spaces.
They are really intended to be used \emph{only} for objects which are
not exported from the name space.  They do attempt to alter a copy
registered as an S3 method if one is found.

They can only be used to change the values of objects in the
name space, not to create new objects.
\end{Note}
\begin{SeeAlso}\relax
\code{\LinkA{get}{get}}, \code{\LinkA{fix}{fix}}, \code{\LinkA{getS3method}{getS3method}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
getFromNamespace("findGeneric", "utils")
## Not run: 
fixInNamespace("predict.ppr", "stats")
stats:::predict.ppr
getS3method("predict", "ppr")
## alternatively
fixInNamespace("predict.ppr", pos = 3)
fixInNamespace("predict.ppr", pos = "package:stats")
## End(Not run)\end{ExampleCode}
\end{Examples}

