(This article was first published on

**NIR-Quimiometria**, and kindly contributed to R-bloggers)In my last post about “ChemoSpec package” (Hierarchical Cluster Analysis (ChemoSpec) – 02), we saw the two cluster groups (one for olive oil, other for sunflower oil), and also another sub-clusters for the sunflower oil.

Continue reading the manual “ChemoSpec:An R Package for Chemometric Analysis of Spectroscopic Data” by Bryan A. Hanson, I decide to apply the PCA to the oil data.

PCA is a unsupervised discriminate method and it will give me another vision of the clusters.

Let´s have a look first to the HCA plot from (Hierarchical Cluster Analysis (ChemoSpec) – 02):

Lets calculate the PCA for the same data (remember that the spectra is math treated with the second derivative).I will use the option “classical” from the two main options (classical and robust).

>class<-classPCA(oils,choice=”noscale”)

>plotScores(oils,title=”OilsSpectra”,class,

>plotScores(oils,title=”OilsSpectra”,class,

+ pcs=c(1,2),ellipse=”none”,tol=0.01)

If we realize, we have similar information in both plots: One cluster for olive oil (red point to the left) and to the right other sub-clusters (3) for the sunflower oil.

This two PCs explain almost all the variance (99,4%).

To

**leave a comment**for the author, please follow the link and comment on their blog:**NIR-Quimiometria**.R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...