# Plotting the “Mean Spectrum”

[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.

**NIR-Quimiometría**, 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.

Mean spectrum calculation is important:

*To center a matrix of spectra, we subtract the mean spectrum, from every spectrum in the matrix.*

*There are also many options to use the mean spectrum, like average subsamples.*

Let´s calculate and plot the mean spectra for the Yarn NIR Data:

**> yarn_mean<-colMeans(yarn$NIR)**

**> wavelength<-c(1:268)**

**> matplot(wavelength,yarn_mean,lty=1,pch=21,col=”red”,**

**+ xlab=”data_points”,ylab=”mean spec.”)**

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 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.