\Header{princomp}{Principal Components Analysis}
\alias{plot.princomp}{princomp}
\alias{print.princomp}{princomp}
\alias{predict.princomp}{princomp}
\alias{summary.princomp}{princomp}
\keyword{multivariate}{princomp}
\begin{Usage}
\begin{verbatim}
princomp(x, cor = FALSE, scores = TRUE,
         subset = rep(TRUE, nrow(as.matrix(x))))

print(obj,...)  summary(obj)  plot(obj,...)  predict(obj,...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\texttt{x}] a matrix (or data frame) which provides the data for the
principal components analysis.
\item[\texttt{cor}] a logical value indicating whether the calculation should
use the correlation matrix or the covariance matrix.
\item[\texttt{score}] a logical value indicating whether the score on each
principal component should be calculated.
\item[\texttt{subset}] a vector used to select rows (observations) of the
data matrix \texttt{x}.
\item[\texttt{obj}] an object of class \texttt{"princomp"}, as from \texttt{princomp()}.
\end{ldescription}
\end{Arguments}
\begin{Description}
Performs a principal components analysis on the given data matrix
and returns the results as a \texttt{princomp} object.\end{Description}
\begin{Details}
The calculation is done using \texttt{\Link{eigen}} on the correlation or
covariance matrix, as determined by \texttt{\Link{cor}}.  This is done for
compatibility with the Splus result (even though alternate forms for
\texttt{x}---e.g., a covariance matrix---are not supported as they are
in Splus).  A preferred method of calculation is to use svd on
\texttt{x}, as is done in \texttt{prcomp}.

Note that the scaling of results is affected by the setting of
\texttt{cor}.  If \texttt{cor} is \texttt{TRUE} then the divisor in the
calculation of the sdev is N-1, otherwise it is N.  This has the
effect that the result is slightly different depending on whether
scaling is done first on the data and cor set to \texttt{FALSE}, or 
done automatically in \texttt{princomp} with \texttt{cor = TRUE}.

The \texttt{\Link{print}} method for the these objects prints the
results in a nice format and the \texttt{\Link{plot}} method produces
a scree plot.\end{Details}
\begin{Value}
\texttt{princomp} returns a list with class \texttt{"princomp"}
containing the following components:
\begin{ldescription}
\item[\texttt{var}] the variances of the principal components
(i.e., the eigenvalues)
\item[\texttt{load}] the matrix of variable loadings (i.e., a matrix
whose columns contain the eigenvectors).
\item[\texttt{scale}] the value of the \texttt{scale} argument.
\end{ldescription}
\end{Value}
\begin{References}
Mardia, K. V., J. T. Kent and J. M. Bibby (1979).
\emph{Multivariate Analysis}, London: Academic Press.

Venables, W. N. and B. D. Ripley (1997).
\emph{Modern Applied Statistics with S-Plus}, Springer-Verlag.\end{References}
\begin{SeeAlso}
\texttt{\Link{prcomp}}, \texttt{\Link{cor}}, \texttt{\Link{cov}},
\texttt{\Link{eigen}}.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
## the variances of the variables in the
## crimes data vary by orders of magnitude
data(crimes)
(pc.cr <- princomp(crimes))
princomp(crimes, cor = TRUE)
princomp(scale(crimes, scale = TRUE, center = TRUE), cor = FALSE)

summary(pc.cr <- princomp(crimes))
loadings(pc.cr)
plot(pc.cr)
biplot(pc.cr)
\end{ExampleCode}
\end{Examples}

