# PCA with "ChemoSpec" – 001

[This article was first published on

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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.**NIR-Quimiometria**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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 about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.