\Header{model.tables}{Compute Tables of Results from an Aov Model Fit.}
\methalias{model.tables.aov}{model.tables}
\methalias{model.tables.aovlist}{model.tables}
\alias{print.tables.aov}{model.tables}
\keyword{models}{model.tables}
\begin{Description}\relax
Computes summary tables for model fits, especially complex \code{aov} fits.\end{Description}
\begin{Usage}
\begin{verbatim}
model.tables(x, ...)
model.tables.aov(x, type = "effects", se = FALSE, cterms, ...)
model.tables.aovlist(x, type = "effects", se = FALSE, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] a model object, usually produced by \code{aov}
\item[\code{type}] type of table: currently only \code{"effects"} and
\code{"means"} are implemented.
\item[\code{se}] should standard errors be computed?
\item[\code{cterms}] A character vector giving the names of the terms for
which tables should be computed. The default is all tables.
\item[\code{...}] further arguments passed to or from other methods.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
For \code{type = "effects"} give tables of the coefficients for each
term, optionally with standard errors.

For \code{type = "means"} give tables of the mean response for each
combinations of levels of the factors in a term.\end{Details}
\begin{Value}
An object of class \code{"tables.aov"}, as list which may contain components
\begin{ldescription}
\item[\code{tables}] A list of tables for each requested term.
\item[\code{n}] The replication information for each term.
\item[\code{se}] Standard error information.
\end{ldescription}
\end{Value}
\begin{Section}{Warning}
The implementation is incomplete, and only the simpler
cases have been tested thoroughly.\end{Section}
\begin{Author}\relax
B.D. Ripley\end{Author}
\begin{SeeAlso}\relax
\code{\Link{aov}}\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
## From Venables and Ripley (1997) p.210.
N <- c(0,1,0,1,1,1,0,0,0,1,1,0,1,1,0,0,1,0,1,0,1,1,0,0)
P <- c(1,1,0,0,0,1,0,1,1,1,0,0,0,1,0,1,1,0,0,1,0,1,1,0)
K <- c(1,0,0,1,0,1,1,0,0,1,0,1,0,1,1,0,0,0,1,1,1,0,1,0)
yield <- c(49.5,62.8,46.8,57.0,59.8,58.5,55.5,56.0,62.8,55.8,69.5,
55.0, 62.0,48.8,45.5,44.2,52.0,51.5,49.8,48.8,57.2,59.0,53.2,56.0)

npk <- data.frame(block=gl(6,4), N=factor(N), P=factor(P),
                  K=factor(K), yield=yield)
npk.aov <- aov(yield ~ block + N*P*K, npk)
model.tables(npk.aov, "means", se=TRUE)

## as a test, not particularly sensible statistically
options(contrasts=c("contr.helmert", "contr.treatment"))
npk.aovE <- aov(yield ~  N*P*K + Error(block), npk)
model.tables(npk.aovE,  se=TRUE)
model.tables(npk.aovE, "means")
\end{ExampleCode}
\end{Examples}

