(This article was first published on

**NIR-Quimiometría**, and kindly contributed to R-bloggers)As I told you I´m a beginner in “R”, so I realize that I have to prepare my data a little bit in order to continue from my previous post ( NIT: Fatty acids study in R – Part 002) after getting some errors.

Anyway I´m really fascinated with this program, so sorry if I make some confusion.

Anyway I´m really fascinated with this program, so sorry if I make some confusion.

**> fattyac_msc<-data.frame(C16_0=I(C16_0),C16_1=I(C16_1),C18_0=I(C18_0),**

**+ C18_1=I(C18_1),C18_2=I(C18_2),C18_3=I(C18_3),NITmsc=I(fat_msc))**

**> names(fattyac_msc)**

**[1] “C16_0” “C16_1” “C18_0” “C18_1” “C18_2” “C18_3” “NITmsc”**

Let´s plot the X (spectra) matrix treated with MSC and centered (Fig 1)

**> fattyac_msc_c<-scale(fattyac_msc$NITmsc,center = TRUE,scale = FALSE)**

**> matplot(wavelengths,t(fattyac_msc_c),lty=1,pch=21,**

**+ xlab=”data_points”,ylab=”Abs”)**

Let´s plot the X (spectra) Standard Deviation Spectrum of this centered matrix (Fig 2)

**> sdfattyac_msc_c<-sd(fattyac_msc_c)**

**> matplot(wavelengths,sdfattyac_msc_c,lty=1,pch=21,**

**+ xlab=”data_points”,ylab=”Abs”)**

Let´s have a look again to the original spectra treated with MSC:

It is clear the sample which has a high MD

*(Mahalanobis Distance)*value, a clear outlier. We will see, which characteristics has this sample*(along this study)*and if it should be excluded or maintained for the calibrationWe saw the scores in the previous post, let´s have a look to the loadings.

**> fatmsc_nipalsP4pc<-fatmsc_nipals$P[,1:4]**

**> loading1<-fatmsc_nipalsP4pc[,1]**

**> loading2<-fatmsc_nipalsP4pc[,2]**

**> loading3<-fatmsc_nipalsP4pc[,3]**

**> loading4<-fatmsc_nipalsP4pc[,4]**

It is interesting to find interpretation to these plots, for this is important to look carefully to all the plots (scores,loadings, original spectra,…), and also to consult bibliography about the position of the NIT bands for C-H, O-H,.., bonds.

To

**leave a comment**for the author, please follow the link and comment on their blog:**NIR-Quimiometría**.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...