Principal Component Analysis (PCA) is a statistical procedure that uses an orthogonal transformation to convert a set of observations of possibly correlated variables into set of values of linearly un correlated variables. (from wiki)
R can preform PCA very simple command “prcomp”.
The result can visualise using biplot function.
ggplot2 is a plotting system for R, it can make very rich graphs using simple command.
I want to draw biplot using ggplot2, and found good package “ggbiplot”.
If you interested in that, you can install following command :-).
From R command prompt.
install.packages("devtools") # also need install ggplot2 library("devtools") install_github("ggbiplot", "vqv")
OK, let’s draw biplot
> library("ggbiplot") > data(wine) > wine.pca <- prcomp(wine,scale.=TRUE) > g<-ggbiplot(wine.pca, obs.scale=1, var.scale=1, groups=wine.class, ellipse=TRUE, circle=TRUE) > g<-g+scale_color_discrete(name="") > g<-opts(legend.discription="horiz",legend.posion="top") Error: 'opts' is deprecated. Use 'theme' instead. (Defunct; last used in version 0.9.1) # opps! I got error > print(g)