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

