\Header{contrasts}{Get and Set Contrast Matrices}
\alias{contrasts<\Rdash}{contrasts}
\keyword{design}{contrasts}
\keyword{regression}{contrasts}
\begin{Description}\relax
Set and view the contrasts associated with a factor.\end{Description}
\begin{Usage}
\begin{verbatim}
contrasts(x)
contrasts(x) <- ctr
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] a factor.
\item[\code{ctr}] either a matrix whose columns give coefficients for
contrasts in the levels of \code{x}, or the (quoted) name of a
function which computes such matrices.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
If contrasts are not set for a factor the default functions from
\code{\Link{options}("contrasts")} are used.\end{Details}
\begin{SeeAlso}\relax
\code{\Link{C}},
\code{\Link{contr.helmert}},
\code{\Link{contr.poly}},
\code{\Link{contr.sum}},
\code{\Link{contr.treatment}};
\code{\Link{glm}},
\code{\Link{aov}},
\code{\Link{lm}}.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
example(factor)
(fff <- factor(ff))
contrasts(fff) # treatment
contrasts(C(fff, sum))
\end{ExampleCode}
\end{Examples}

