Dimensional analysis
Principal compenent analysis (PCA)

There are two function in the basics stats package prcomp() and princomp() and three functions in packages from the French school of data analysis PCA() {FactoMineR} dudi.pca() {ade4} and acp() {amap}.

You will have to look up the documentation for the details, below you will only find some examples for the most common tasks.

princomp (prcomp) performs a principal components analysis on a numeric data matrix and returns the results as an object of class princomp (prcomp).

• princomp(~urb+infmor+lifeem+gnpcap+gnpagr+gnpserv+lit,data=world) Perform a PCA (you can also supply a matrix index of a list of variables (formula style).
• princomp(~urb+infmor+lifeem+gnpcap+gnpagr+gnpserv+lit,data=world, cor=TRUE, scores=TRUE) same, but use correlation matrix (default covariance matrix) and produce factor scores
• pca <- princomp(~urb+infmor+lifeem+gnpcap+gnpagr+gnpserv+lit,data=world, cor=TRUE, scores=TRUE) same, results are stored into pca
• plot(pca) Histogram of the eigenvalues
• summary(pca) display summary of results
• plot(pca\$scores) simple plot of the scores stored in the princomp object
• bibplot(pca) Produce a biplot (with both scores and loadings (Gabriel's biplot)

A nicer plot for the scores (using {ggplot2}

• scores <-as.data.frame(pca\$scores) assign the scores to an object (ggplot requires a data frame)
• ggplot(data = scores, aes(x = Comp.1, y = Comp.2, label = rownames(scores))) + geom_text(colour = "blue", alpha = 0.8, size = 2) + ggtitle("PCA of some world data")

A simple loadings plot with labels (using base graphics); plots by default the first two components