\Header{prcomp}{Principal Components Analysis}
\alias{plot.prcomp}{prcomp}
\alias{print.prcomp}{prcomp}
\alias{summary.prcomp}{prcomp}
\alias{print.summary.prcomp}{prcomp}
\begin{Usage}
\begin{verbatim}
prcomp(x, retx = TRUE, center = TRUE, scale. = FALSE, tol = NULL)
\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{retx}] a logical value indicating whether the rotated variables
should be returned.
\item[\texttt{center}] a logical value indicating whether the variables
should be shifted to be zero centered. Alternately, a vector of
length equal the number of columns of \texttt{x} can be supplied.
The value is passed to \texttt{scale}.
\item[\texttt{scale}] a logical value indicating whether the variables should
be scaled to have unit variance before the analysis takes
place. The default is \texttt{FALSE} for consistency with S, but
in general scaling is advisable. Alternately, a vector of length
equal the number of columns of \texttt{x} can be supplied.  The
value is passed to \texttt{scale}.
\item[\texttt{tol}] a value indicating the magnitude below which components
should be omitted. With the default null setting, no components
are omitted.  Other settings for tol could be \texttt{tol = 0} or
\texttt{tol = sqrt(.Machine\$double.eps)}.
\end{ldescription}
\end{Arguments}
\begin{Description}
Performs a principal components analysis on the given data matrix
and returns the results as a \texttt{prcomp} object.\end{Description}
\begin{Details}
The calculation is done with svd on the data matrix, not by using
eigen on the covariance matrix.  This is generally the preferred
method for numerical accuracy.  The print method for the these
objects prints the results in a nice format and the plot method
produces a scree plot.\end{Details}
\begin{Value}
\texttt{prcomp} returns an list with class \texttt{"prcomp"}
containing the following components:
\begin{ldescription}
\item[\texttt{sdev}] the standard deviation of the principal components
(i.e., the eigenvalues of the cov matrix, though the calculation
is actually done with the singular values of the data matrix).
\item[\texttt{rotation}] the matrix of variable loadings (i.e., a matrix
whose olumns contain the eigenvectors).  The function
\texttt{princomp} returns this in the element \texttt{loadings}.
\item[\texttt{x}] if \texttt{retx} is true the value of the rotated data (the
data multiplied by the \texttt{rotation} matrix) is returned.
\end{ldescription}
\end{Value}
\begin{References}
Mardia, K. V., J. T. Kent, J and 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{princomp}}, \texttt{\Link{cor}}, \texttt{\Link{cov}},
\texttt{\Link{svd}}, \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)
prcomp(crimes)
prcomp(crimes, scale = TRUE)
plot(prcomp(crimes))
summary(prcomp(crimes))
\end{ExampleCode}
\end{Examples}

