\Header{check.options}{Set Options with Consistency Checks}
\keyword{utilities}{check.options}
\keyword{programming}{check.options}
\begin{Usage}
\begin{verbatim}
check.options(new, name.opt, reset=FALSE, assign.opt=FALSE,
              envir=.GlobalEnv, check.attributes=c("mode", "length"),
              override.check=FALSE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\texttt{new}] a \emph{named} list
\item[\texttt{name.opt}] character with the name of \R\ object containing the
``model'' (default) list.
\item[\texttt{reset}] logical; if \texttt{TRUE}, reset the options from
\texttt{name.opt}.  If there is more than one \R\ object with name
\texttt{name.opt}, remove the first one in the \texttt{\Link{search}()} path.
\item[\texttt{assign.opt}] logical; if \texttt{TRUE}, assign the ...
\item[\texttt{envir}] the \texttt{\Link{environment}} used for \texttt{\Link{get}}
and \texttt{\Link{assign}}.
\item[\texttt{check.attributes}] character containing the attributes which
\texttt{check.options} should check.
\item[\texttt{override.check}] logical vector of length \texttt{length(new)} (or 1
which entails recycling).
For those \texttt{new[i]} where \texttt{override.check[i] == TRUE}, the
checks are overriden and the changes made anyway.
\end{ldescription}
\end{Arguments}
\begin{Description}
Utility function for setting options with some consistency checks.
The \texttt{\Link{attributes}} of the new settings in \texttt{new} are
checked for consistency with the \emph{model} (often default)
list in \texttt{name.opt}.\end{Description}
\begin{Value}
A list of components with the same names as the one called
\texttt{name.opt}.
The values of the components are changed from the \texttt{new} list,
as long as these pass the checks (when these are not overridden
according to \texttt{override.check}).\end{Value}
\begin{Author}
Martin Maechler\end{Author}
\begin{SeeAlso}
\texttt{\Link{ps.options}} which uses \texttt{check.options}.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
L1 <- list(a=1:3, b=pi, ch="CH")
str(L2 <- check.options(list(a=0:2), name.opt = "L1"))
str(check.options(NULL,reset = TRUE, name.opt = "L1"))
\end{ExampleCode}
\end{Examples}

