<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2424328492215531658</id><updated>2026-05-31T02:47:24.611+02:00</updated><category term="R-Chemometrics"/><category term="Learning Win ISI"/><category term="NIR Soil Analysis"/><category term="R-Tutorials"/><category term="Noticias"/><category term="Principal Components"/><category term="Matrices"/><category term="Caret"/><category term="Monitor function"/><category term="Distancia Mahalanobis"/><category term="Magazine"/><category term="Video: R-Chemometrics"/><category term="LOCAL"/><category term="Resemble"/><category term="Shootout 2002"/><category term="Diagnostics"/><category term="Statistics / Estadisticos"/><category term="PLS package"/><category term="Unscrambler"/><category term="Learning Foss Calibrator"/><category term="Fundamentos"/><category term="VIDEO: R-Tutorials"/><category term="Derivatives"/><category term="Fotografía"/><category term="LUCAS database"/><category term="Soil Analysis"/><category term="PCR"/><category term="Trat. Anti-Scatter"/><category term="Excel Tutorials"/><category term="Quimiometría"/><category term="Video-Excel"/><category term="Aplicaciones"/><category term="Regresiones MLR"/><category term="Sample presentation"/><category term="soilspec"/><category term="#tidytuesday:Eurovision"/><category term="Curso Algebra Lineal"/><category term="NIT: Fatty acids study in R"/><category term="Prospectr package"/><category term="R"/><category term="Video-Fundamentals"/><category term="Discriminantes"/><category term="Quimiometría_Tratamientos"/><category term="Resamble"/><category term="Sampling (Muestreo)"/><category term="Shoot-out"/><category term="Tidyverse"/><category term="Tutoriales de Foss Calibrator"/><category term="Curso Quimiometría UHU"/><category term="Looking at the spectra"/><category term="Shootout 2012"/><category term="Video Lectures: Chemometrics"/><category term="Applied Predictive Modeling"/><category term="Bias"/><category term="Gráficos"/><category term="HACKATON Calibration Transfer"/><category term="Regresión"/><category term="Standards"/><category term="tidymodels"/><category term="Artificial Neural Networks"/><category term="Bibliography"/><category term="Classical Least Square"/><category term="Ejercicios."/><category term="ISI Scan"/><category term="NIT Tutorial"/><category term="Análisis Cualitativo"/><category term="Chemometrics package"/><category term="MOSAIC"/><category term="Métodos de referencia"/><category term="Process"/><category term="Random Forest"/><category term="3D plots"/><category term="Calibration transfer"/><category term="Hyperspectral Imaging"/><category term="Indicator Variables"/><category term="Infratec Tools"/><category term="Machine Learning"/><category term="Puerto de Avilés"/><category term="Subscripciones a este Blog:¿Como?"/><category term="Vision Software"/><category term="pedometrics"/><category term="tidytuesday"/><category term="2D plots"/><category term="ANN"/><category term="Applied Predictive Modelling"/><category term="Bases de datos"/><category term="Books"/><category term="Distancia Euclidiana"/><category term="Github"/><category term="Hardware"/><category term="Historia de la Ciencia"/><category term="ISO 12099"/><category term="Import/Export"/><category term="Instrumentation"/><category term="Instruments"/><category term="Inverse Least Square"/><category term="MSC"/><category term="Math Video Lecture"/><category term="Monitoring"/><category term="NASA"/><category term="Petfood"/><category term="Pracma"/><category term="Presentación de muestra"/><category term="R-Robust Statistics"/><category term="R-Studio Conferences"/><category term="Reader Questions"/><category term="Shootout 2016"/><category term="Shopping"/><category term="Soil Analysis tutorials"/><category term="Técnicas de muestreo"/><category term="Video Tutoliales para Tablets"/><category term="Videos R en español"/><category term="Webinars Soil"/><category term="Win ISI Software"/><category term="XDS"/><category term="meat meal"/><title type='text'>R &amp;amp; Chemometrics</title><subtitle type='html'>R for Statistics and Near Infrared spectroscopy </subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://nir-quimiometria.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://nir-quimiometria.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>José Ramón Cuesta</name><uri>http://www.blogger.com/profile/01637083082643255576</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>956</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2424328492215531658.post-4571054506390432595</id><published>2026-05-27T21:14:33.809+02:00</published><updated>2026-05-27T21:14:33.809+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Excel Tutorials"/><category scheme="http://www.blogger.com/atom/ns#" term="Matrices"/><title type='text'>Ejercicio 1: Utilidad de resta de matrices en espectroscopia</title><content type='html'>&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Para seguir este espectro se dispone de la matriz de espectros &quot;fish_1_19&quot; que es una matriz de espectros&amp;nbsp; que preparé en el post anterior y vamos a calcular el espectro medio, simplemente haciendo la media de cada columna (absorbancias a las 19 longitudes de onda) con Excel.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEi_EHHQq4g1_Ss-RBvNAf9lGV57NQAHHwpy2U7mwnJHh2YJ32zlP6T1r26a09nHSSflhT1OwOUSupD-uoLyLugHPVqqaW2_PAo7k7ij4mnqvGFuruUtbKnggJb1jZf_V1C41TKodCszM5tlCKR_hupG2XjK00W3MLidQTcScffoiYVOfikkalDlXKzwpnpr&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;715&quot; data-original-width=&quot;1095&quot; height=&quot;380&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEi_EHHQq4g1_Ss-RBvNAf9lGV57NQAHHwpy2U7mwnJHh2YJ32zlP6T1r26a09nHSSflhT1OwOUSupD-uoLyLugHPVqqaW2_PAo7k7ij4mnqvGFuruUtbKnggJb1jZf_V1C41TKodCszM5tlCKR_hupG2XjK00W3MLidQTcScffoiYVOfikkalDlXKzwpnpr=w581-h380&quot; width=&quot;581&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Extendemos la fórmula a las demás longitudes de onda&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Y a ese espectro medio lo vamos a llamar el vector &quot;Raw Mean Spectrum&quot; para usarlo a continuación.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgiV-Np42nP7oNboCMmGNn19q40YAMZXdCyhJUMhum3eN_rK254rOTPSaKSN9yhh5pZSW2Ineb2wLikeJjZkVA878Apm8CbN2Cx3CpgeCqGYlnE5DTYiJQ_rMOyHwM1CnOBDX7P2XW1shTlPzxOLk-IFKHmHy115XNFW225_o0l3PhUpowFqL5jvEEzxsLA&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;718&quot; data-original-width=&quot;1113&quot; height=&quot;384&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgiV-Np42nP7oNboCMmGNn19q40YAMZXdCyhJUMhum3eN_rK254rOTPSaKSN9yhh5pZSW2Ineb2wLikeJjZkVA878Apm8CbN2Cx3CpgeCqGYlnE5DTYiJQ_rMOyHwM1CnOBDX7P2XW1shTlPzxOLk-IFKHmHy115XNFW225_o0l3PhUpowFqL5jvEEzxsLA=w596-h384&quot; width=&quot;596&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Y a continuación hacemos la resta de la matriz &quot;Fish_1_19&quot; de &quot;Raw_Mean_Spectrum&quot;.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhFKc5X5xTc962dSniJzmQHcH7BucWmJIs23drejINsX-3A0vU8SXpTBkIZYzW7pCT0sietD9TnLI8d_Str7m648N_x27ul0MzkG2IykOkKmYrCn6u_YAKGxbPcCFrs44tk_0EuiTh2vcGXbz34CbkQOeHVKys9yWPDzq8Z9hHW1wxC3BFbn_TSnyTUVO3X&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;714&quot; data-original-width=&quot;1085&quot; height=&quot;397&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhFKc5X5xTc962dSniJzmQHcH7BucWmJIs23drejINsX-3A0vU8SXpTBkIZYzW7pCT0sietD9TnLI8d_Str7m648N_x27ul0MzkG2IykOkKmYrCn6u_YAKGxbPcCFrs44tk_0EuiTh2vcGXbz34CbkQOeHVKys9yWPDzq8Z9hHW1wxC3BFbn_TSnyTUVO3X=w601-h397&quot; width=&quot;601&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://nir-quimiometria.blogspot.com/feeds/4571054506390432595/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://nir-quimiometria.blogspot.com/2026/05/ejercicio-1-utilidad-de-resta-de.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/4571054506390432595'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/4571054506390432595'/><link rel='alternate' type='text/html' href='http://nir-quimiometria.blogspot.com/2026/05/ejercicio-1-utilidad-de-resta-de.html' title='Ejercicio 1: Utilidad de resta de matrices en espectroscopia'/><author><name>José Ramón Cuesta</name><uri>http://www.blogger.com/profile/01637083082643255576</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEi_EHHQq4g1_Ss-RBvNAf9lGV57NQAHHwpy2U7mwnJHh2YJ32zlP6T1r26a09nHSSflhT1OwOUSupD-uoLyLugHPVqqaW2_PAo7k7ij4mnqvGFuruUtbKnggJb1jZf_V1C41TKodCszM5tlCKR_hupG2XjK00W3MLidQTcScffoiYVOfikkalDlXKzwpnpr=s72-w581-h380-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2424328492215531658.post-1695373863637646418</id><published>2026-05-27T16:56:09.184+02:00</published><updated>2026-05-27T16:57:00.921+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Excel Tutorials"/><category scheme="http://www.blogger.com/atom/ns#" term="Matrices"/><title type='text'>Simulando espectros de un NIR de 19 filtros en Excel </title><content type='html'>&lt;p style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;&lt;span style=&quot;font-family: verdana;&quot;&gt;A partir de un equipo NIR de rango 400 a 2498 cada dos nanómetros hemos seleccionado las 19 longitudes de onda correspondientes a los 19 filtros de un equipo Bran + Lubbe InfraAlyzer (&lt;a href=&quot;https://nir-quimiometria.blogspot.com/2026/05/planificando-hacer-una-base-de-datos.html&quot; target=&quot;_blank&quot;&gt;ver anterior post&lt;/a&gt;). Por supuesto que es una gran perdida de datos, pero la idea de los siguientes posts es hacer análisis matriciales más simples para entender conceptos quimiométricos en Excel y de este modo será mucho mas pedagógico.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhf0yLUn0ZZqiUOolEg23pRmP7RqygGX9hOKcPAk9KCxfCBri12yEX9hHEww9MgoL3nPtfXDfRMiOMcAO7fAKTl87IwQdjymymjNSZy8Q4mAaMPmZrti2waXfW2y-T6RpziQ1IQvRmXdfasU602y62Q5Vyg6aWKfZdnnbaRm9GhjBc5Zlo005Lay3BknSHI&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;638&quot; data-original-width=&quot;1196&quot; height=&quot;310&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhf0yLUn0ZZqiUOolEg23pRmP7RqygGX9hOKcPAk9KCxfCBri12yEX9hHEww9MgoL3nPtfXDfRMiOMcAO7fAKTl87IwQdjymymjNSZy8Q4mAaMPmZrti2waXfW2y-T6RpziQ1IQvRmXdfasU602y62Q5Vyg6aWKfZdnnbaRm9GhjBc5Zlo005Lay3BknSHI=w580-h310&quot; width=&quot;580&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;En este caso usamos un gráfico de scatter por líneas, pero si visualmente lo deseamos podemos quitarlos y poner solo los puntos.&lt;/span&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://nir-quimiometria.blogspot.com/feeds/1695373863637646418/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://nir-quimiometria.blogspot.com/2026/05/simulando-espectros-de-un-nir-de-19.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/1695373863637646418'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/1695373863637646418'/><link rel='alternate' type='text/html' href='http://nir-quimiometria.blogspot.com/2026/05/simulando-espectros-de-un-nir-de-19.html' title='Simulando espectros de un NIR de 19 filtros en Excel '/><author><name>José Ramón Cuesta</name><uri>http://www.blogger.com/profile/01637083082643255576</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEhf0yLUn0ZZqiUOolEg23pRmP7RqygGX9hOKcPAk9KCxfCBri12yEX9hHEww9MgoL3nPtfXDfRMiOMcAO7fAKTl87IwQdjymymjNSZy8Q4mAaMPmZrti2waXfW2y-T6RpziQ1IQvRmXdfasU602y62Q5Vyg6aWKfZdnnbaRm9GhjBc5Zlo005Lay3BknSHI=s72-w580-h310-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2424328492215531658.post-2414666302431862411</id><published>2026-05-26T22:42:02.156+02:00</published><updated>2026-05-26T22:42:02.156+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Excel Tutorials"/><category scheme="http://www.blogger.com/atom/ns#" term="Matrices"/><title type='text'>Planificando hacer una base de datos espectral para análisis matricial en Excel.</title><content type='html'>&lt;p style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;&lt;span style=&quot;font-family: verdana;&quot;&gt;En los próximos posts vamos a preparar una matriz de datos espectral con un fichero de demo en el que seleccionaremos 19 longitudes de onda determinadas, simulando ser un equipo NIR de filtros Bran+Luebbe .&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Las longitudes de onda serán: 1445, 1680, 1722, 1734, 1759, 1778, 1818, 1940, 1982, 2100, 2139, 2180, 2190, 2208, 2230, 2270, 2310, 2336 y 2348 nm.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;1445 (O-H / Agua))&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;1680-1780&amp;nbsp; (C-H)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1720 - 1760 (Grasas / Lípidos)&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;1940 (O-H / Agua)&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;1980-2180 (N-H / Proteína)&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;2100 (Almidón / Proteína)&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;2170 - 2180 (Proteína)&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;2270-2348 (C-H Combinaciones)&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&amp;nbsp;Con estas selecciones trabajaremos con matrices mas pequeñas y menos intercorrelacionadas para poder entender mejor el análisis quimiométrico en el caso de trabajar con Excel.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://nir-quimiometria.blogspot.com/feeds/2414666302431862411/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://nir-quimiometria.blogspot.com/2026/05/planificando-hacer-una-base-de-datos.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/2414666302431862411'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/2414666302431862411'/><link rel='alternate' type='text/html' href='http://nir-quimiometria.blogspot.com/2026/05/planificando-hacer-una-base-de-datos.html' title='Planificando hacer una base de datos espectral para análisis matricial en Excel.'/><author><name>José Ramón Cuesta</name><uri>http://www.blogger.com/profile/01637083082643255576</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2424328492215531658.post-2754975005212675459</id><published>2026-05-26T14:57:11.743+02:00</published><updated>2026-05-26T14:57:11.743+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Excel Tutorials"/><category scheme="http://www.blogger.com/atom/ns#" term="Matrices"/><title type='text'>Conocimientos básicos: Resta de matrices en Excel</title><content type='html'>&lt;p style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;&lt;span style=&quot;font-family: verdana;&quot;&gt;De gran utilidad es la resta de espectros en quimiometría NIR, por ejemplo, para conocer como ha variado una muestra en el tiempo (restando el espectro actual del original, nos indicará si la muestra a variado en humedad, color,..etc.), o por ejemplo para hacer un centrado espectral que es de lo más común en cálculos de algoritmos como por ejemplo Componentes Principales.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;La resta matricial es muy simple en Excel, y usamos a modo de ejemplo las matrices A y B del post anterior:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjbe2_5Az7WIhYUTEnbc5Q_7TpG8KwttMi-C_whFbXDwENQ1xz7ju2g3ge7Lg0tE-UshUiaEWHHmo6Ep7KWrEtSi6NlxIsgkFBXRdYqLUcmkPv9XNuWbIGYZfYh5RzsRNAb3hgqAK3hn7LBTYR9i_rF__J0BHJOnjOowjK6olWJGLVx9HreAsh_G4DO1ayq&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;312&quot; data-original-width=&quot;857&quot; height=&quot;196&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjbe2_5Az7WIhYUTEnbc5Q_7TpG8KwttMi-C_whFbXDwENQ1xz7ju2g3ge7Lg0tE-UshUiaEWHHmo6Ep7KWrEtSi6NlxIsgkFBXRdYqLUcmkPv9XNuWbIGYZfYh5RzsRNAb3hgqAK3hn7LBTYR9i_rF__J0BHJOnjOowjK6olWJGLVx9HreAsh_G4DO1ayq=w541-h196&quot; width=&quot;541&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;siendo el resultado:&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhpVMVssB2Okt3uQCY2F12ZfiQZhYPRjmc8C6v7hSv8L5889BJtS-vbPZbXAnK0oUr8OEviz5yRB02ILg30IABB-odOrdNbIbOi_UnmUvjvE2G77L3iP42HUzv6Qqo_hTSTaw1fumwOI8EI7yrr9Q7aQVFZCR78VPRch_C0JDF2-lEQ6YjxN9B8gbdFhal6&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;150&quot; data-original-width=&quot;857&quot; height=&quot;94&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhpVMVssB2Okt3uQCY2F12ZfiQZhYPRjmc8C6v7hSv8L5889BJtS-vbPZbXAnK0oUr8OEviz5yRB02ILg30IABB-odOrdNbIbOi_UnmUvjvE2G77L3iP42HUzv6Qqo_hTSTaw1fumwOI8EI7yrr9Q7aQVFZCR78VPRch_C0JDF2-lEQ6YjxN9B8gbdFhal6=w537-h94&quot; width=&quot;537&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://nir-quimiometria.blogspot.com/feeds/2754975005212675459/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://nir-quimiometria.blogspot.com/2026/05/conocimientos-basicos-resta-de-matrices.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/2754975005212675459'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/2754975005212675459'/><link rel='alternate' type='text/html' href='http://nir-quimiometria.blogspot.com/2026/05/conocimientos-basicos-resta-de-matrices.html' title='Conocimientos básicos: Resta de matrices en Excel'/><author><name>José Ramón Cuesta</name><uri>http://www.blogger.com/profile/01637083082643255576</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEjbe2_5Az7WIhYUTEnbc5Q_7TpG8KwttMi-C_whFbXDwENQ1xz7ju2g3ge7Lg0tE-UshUiaEWHHmo6Ep7KWrEtSi6NlxIsgkFBXRdYqLUcmkPv9XNuWbIGYZfYh5RzsRNAb3hgqAK3hn7LBTYR9i_rF__J0BHJOnjOowjK6olWJGLVx9HreAsh_G4DO1ayq=s72-w541-h196-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2424328492215531658.post-1389377346195695586</id><published>2026-05-25T20:28:49.596+02:00</published><updated>2026-05-25T20:29:47.873+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Excel Tutorials"/><category scheme="http://www.blogger.com/atom/ns#" term="Matrices"/><title type='text'>Conocimientos básicos: Suma de matrices en Excel</title><content type='html'>&lt;p style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;&lt;span style=&quot;font-family: verdana;&quot;&gt;Siguiendo con los temas de matrices en Excel, vamos a realizar en este caso la suma de matrices. Para ello usamos la matriz A del post anterior y vamos a sumarla con otra matriz que debe de cumplir la condición de que tiene el mismo numero de columnas y el mismo número de filas. Si quisiésemos llevar esto al análisis espectral sería como hacer una suma de unos espectros con otros.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Ahora lo que hacemos es definir la nueva matriz como B, seleccionar el rango de columnas y filas adecuado y aplicar la formula A + B, siendo A y B las matrices a sumar:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgMbaId3U9S4fOZmUizQ2nOG0FfS0iu88Ml6pgpizlGXCXDJex73AmGVRk616gLiTDUiE_31BiRwlaSy_J-N91aytfaqzMUdu_P5TqV7Z9v9Xoe8mN2sRZI494O9n-30__qxrDfQr3S0150o-N2sFmUHlz3WiuaqWFtknCXwtOx1uuahTGwaoZTSlBqJaCW&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;486&quot; data-original-width=&quot;907&quot; height=&quot;251&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgMbaId3U9S4fOZmUizQ2nOG0FfS0iu88Ml6pgpizlGXCXDJex73AmGVRk616gLiTDUiE_31BiRwlaSy_J-N91aytfaqzMUdu_P5TqV7Z9v9Xoe8mN2sRZI494O9n-30__qxrDfQr3S0150o-N2sFmUHlz3WiuaqWFtknCXwtOx1uuahTGwaoZTSlBqJaCW=w470-h251&quot; width=&quot;470&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Al presionar &quot;enter&quot; nos dará el resultado de la suma:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhxAYJUKZzmVXWIHQFy7YtH9aOCCG_zbs_0uVqz5eldDm8Cm6u1GW9VpZaNUEdug6gzJWptdqH3r9UQMzWXo5-JXkz1fsn9WfiDt_QcvKCGZhIq_Ux-5xUH1opLEeAl0vAXLdDcsgq5ZfWXFhGCi-dCsEP7B6V2Yq7nst21ll3di9pZimvxwycqAQ9ibcz0&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;181&quot; data-original-width=&quot;928&quot; height=&quot;116&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhxAYJUKZzmVXWIHQFy7YtH9aOCCG_zbs_0uVqz5eldDm8Cm6u1GW9VpZaNUEdug6gzJWptdqH3r9UQMzWXo5-JXkz1fsn9WfiDt_QcvKCGZhIq_Ux-5xUH1opLEeAl0vAXLdDcsgq5ZfWXFhGCi-dCsEP7B6V2Yq7nst21ll3di9pZimvxwycqAQ9ibcz0=w598-h116&quot; width=&quot;598&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://nir-quimiometria.blogspot.com/feeds/1389377346195695586/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://nir-quimiometria.blogspot.com/2026/05/conocimientos-basicos-suma-de-matrices.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/1389377346195695586'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/1389377346195695586'/><link rel='alternate' type='text/html' href='http://nir-quimiometria.blogspot.com/2026/05/conocimientos-basicos-suma-de-matrices.html' title='Conocimientos básicos: Suma de matrices en Excel'/><author><name>José Ramón Cuesta</name><uri>http://www.blogger.com/profile/01637083082643255576</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEgMbaId3U9S4fOZmUizQ2nOG0FfS0iu88Ml6pgpizlGXCXDJex73AmGVRk616gLiTDUiE_31BiRwlaSy_J-N91aytfaqzMUdu_P5TqV7Z9v9Xoe8mN2sRZI494O9n-30__qxrDfQr3S0150o-N2sFmUHlz3WiuaqWFtknCXwtOx1uuahTGwaoZTSlBqJaCW=s72-w470-h251-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2424328492215531658.post-6650855680536701143</id><published>2026-05-25T17:55:30.586+02:00</published><updated>2026-05-25T17:55:30.586+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Excel Tutorials"/><title type='text'>Conocimientos básicos: Definiendo matrices en Excel</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;span style=&quot;font-family: verdana;&quot;&gt;Simplemente rellena un rango de celdas en Excel, si imaginamos que se trata de datos de espectros rellenamos datos un rango &lt;b&gt;k.n&lt;/b&gt;, siendo &lt;b&gt;k&lt;/b&gt; el numero de puntos de datos y&lt;b&gt; n&lt;/b&gt; el número de muestras. En Excel podemos ir a fórmulas y en&amp;nbsp; el administrados de nombre (Name Manager), lo nombramos con una letra mayúscula, por ejemplo &lt;b&gt;A&lt;/b&gt;.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Usemos por ejemplo los datos que aparecen en el libro &quot;Chemometrics in Excel&quot;:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEi-g99NU7iQyfhrCUeUeO0jwiEhgE0-emz_Hf1URvbnBVDg90jRPvp7Pb75BePso7qz9ne5sTVKt4q85LixsLTwenpImhdodmZCZIbiwgBPSrNFA7WCRmj_qi36FqAk9Yn9o5BffZG3ZTDdnAdOpA2-Ori6pQMr-RbXy2H3RV-DM9oEcarpc5y2f443pIcR&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;483&quot; data-original-width=&quot;601&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEi-g99NU7iQyfhrCUeUeO0jwiEhgE0-emz_Hf1URvbnBVDg90jRPvp7Pb75BePso7qz9ne5sTVKt4q85LixsLTwenpImhdodmZCZIbiwgBPSrNFA7WCRmj_qi36FqAk9Yn9o5BffZG3ZTDdnAdOpA2-Ori6pQMr-RbXy2H3RV-DM9oEcarpc5y2f443pIcR&quot; width=&quot;299&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Para representarlos gráficamente simplemente seleccionamos la matriz y en Insertar, seleccionamos los gráficos en 2D.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Como veis hemos representado una matriz A y con ella hemos visualizado los espectros. Imaginaros que se trata de un equipo con tres filtros de tres determinadas longitudes de onda y por los que hemos analizado tres muestras. Mas adelante lo haremos con espectros reales de equipos con un mayor numero de longitudes de onda.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Podemos hacer ahora una operación sencilla con esa matriz (multiplicarla por 3). Para ello seleccionamos un rango de celdas de 3.4 y en la primera celda escribimos =3*A y al presionar &quot;enter&quot; nos sale la nueva matriz.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhRxOB6O9tYqjNdXkKib_LWXfIA_E8jsQc8x2LbULCwRoLCRFS1ZytJMgsN_uOEOmvD_Gv2QdoscUtMEvq2AiHrVTKlQtvybExfiwZsbg_hF0HR0hEyTVexKfJ0gRDZPMbEin10kPFA84d_LGK3d47Y_QG6RMfCXHpK-Gs28js_vhObLbg7p-W28Nv1LWeY&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;201&quot; data-original-width=&quot;1027&quot; height=&quot;120&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhRxOB6O9tYqjNdXkKib_LWXfIA_E8jsQc8x2LbULCwRoLCRFS1ZytJMgsN_uOEOmvD_Gv2QdoscUtMEvq2AiHrVTKlQtvybExfiwZsbg_hF0HR0hEyTVexKfJ0gRDZPMbEin10kPFA84d_LGK3d47Y_QG6RMfCXHpK-Gs28js_vhObLbg7p-W28Nv1LWeY=w611-h120&quot; width=&quot;611&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;Entender bien como funciona el análisis matricial es importante a la hora de comprender los fundamentos de la quimiometría.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://nir-quimiometria.blogspot.com/feeds/6650855680536701143/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://nir-quimiometria.blogspot.com/2026/05/conocimientos-basicos-definiendo.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/6650855680536701143'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/6650855680536701143'/><link rel='alternate' type='text/html' href='http://nir-quimiometria.blogspot.com/2026/05/conocimientos-basicos-definiendo.html' title='Conocimientos básicos: Definiendo matrices en Excel'/><author><name>José Ramón Cuesta</name><uri>http://www.blogger.com/profile/01637083082643255576</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEi-g99NU7iQyfhrCUeUeO0jwiEhgE0-emz_Hf1URvbnBVDg90jRPvp7Pb75BePso7qz9ne5sTVKt4q85LixsLTwenpImhdodmZCZIbiwgBPSrNFA7WCRmj_qi36FqAk9Yn9o5BffZG3ZTDdnAdOpA2-Ori6pQMr-RbXy2H3RV-DM9oEcarpc5y2f443pIcR=s72-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2424328492215531658.post-4281853489203399464</id><published>2026-05-25T15:12:18.075+02:00</published><updated>2026-05-25T15:12:18.075+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="NIR Soil Analysis"/><title type='text'>Descarga y trabaja con datos de suelos en NIR</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;span style=&quot;font-family: verdana;&quot;&gt;Una de las páginas donde te puedes descargar datos de espectros de suelos con sus métodos de referencia es en&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;ZENODO: &lt;a href=&quot;https://zenodo.org/records/11204174&quot; target=&quot;_blank&quot;&gt;Agroscope_SoilSpectralLibrary_2024&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;You can download soil spectra analysis to work with from:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;ZENODO: &lt;/span&gt;&lt;a href=&quot;https://zenodo.org/records/11204174&quot; style=&quot;font-family: verdana;&quot; target=&quot;_blank&quot;&gt;Agroscope_SoilSpectralLibrary_2024&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://nir-quimiometria.blogspot.com/feeds/4281853489203399464/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://nir-quimiometria.blogspot.com/2026/05/descarga-y-trabaja-con-datos-de-suelos.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/4281853489203399464'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/4281853489203399464'/><link rel='alternate' type='text/html' href='http://nir-quimiometria.blogspot.com/2026/05/descarga-y-trabaja-con-datos-de-suelos.html' title='Descarga y trabaja con datos de suelos en NIR'/><author><name>José Ramón Cuesta</name><uri>http://www.blogger.com/profile/01637083082643255576</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2424328492215531658.post-6491431325476090035</id><published>2025-10-06T19:24:00.003+02:00</published><updated>2025-10-06T19:24:41.055+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Github"/><title type='text'>Git and Github for R Users</title><content type='html'>&lt;div style=&quot;text-align: center;&quot;&gt;&lt;iframe frameborder=&quot;0&quot; height=&quot;270&quot; src=&quot;https://youtube.com/embed/v0QXV6kf5Io?si=QJ2uwmdEhiSUPEJf&quot; style=&quot;background-image: url(https://i.ytimg.com/vi/v0QXV6kf5Io/hqdefault.jpg);&quot; width=&quot;480&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://nir-quimiometria.blogspot.com/feeds/6491431325476090035/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/10/git-and-github-for-r-users.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/6491431325476090035'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/6491431325476090035'/><link rel='alternate' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/10/git-and-github-for-r-users.html' title='Git and Github for R Users'/><author><name>José Ramón Cuesta</name><uri>http://www.blogger.com/profile/01637083082643255576</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/v0QXV6kf5Io/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2424328492215531658.post-4191003859506748604</id><published>2025-10-02T21:04:00.004+02:00</published><updated>2025-10-03T20:43:39.612+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="tidymodels"/><title type='text'>Introduction to machine learning with {tidymodels}</title><content type='html'>&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;iframe frameborder=&quot;0&quot; height=&quot;270&quot; src=&quot;https://youtube.com/embed/qFvbzUivIHY?si=B38si3NCwxwty9B6&quot; style=&quot;background-image: url(https://i.ytimg.com/vi/qFvbzUivIHY/hqdefault.jpg);&quot; width=&quot;480&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;How to create the project with all the necessary data to follow the workshop:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;1 - In RStudio select: &lt;b&gt;File - New Project - Version Control - Git&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;2 - In the repository URL paste:&amp;nbsp;&lt;b&gt;https://github.com/nrennie/nhs-r-tidymodels.git&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;3 - &lt;b&gt;Choose the folder&lt;/b&gt; and &lt;b&gt;Create the project&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://nir-quimiometria.blogspot.com/feeds/4191003859506748604/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/10/introduction-to-machine-learning-with.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/4191003859506748604'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/4191003859506748604'/><link rel='alternate' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/10/introduction-to-machine-learning-with.html' title='Introduction to machine learning with {tidymodels}'/><author><name>José Ramón Cuesta</name><uri>http://www.blogger.com/profile/01637083082643255576</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/qFvbzUivIHY/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2424328492215531658.post-7851333935212876620</id><published>2025-10-02T20:38:00.001+02:00</published><updated>2025-10-02T20:38:24.303+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="tidymodels"/><title type='text'>Get started with tidymodels and classification of penguin data</title><content type='html'>&lt;div style=&quot;text-align: center;&quot;&gt;&lt;iframe frameborder=&quot;0&quot; height=&quot;270&quot; src=&quot;https://youtube.com/embed/z57i2GVcdww?si=j0v2QoUTW5OOXCSu&quot; width=&quot;480&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://nir-quimiometria.blogspot.com/feeds/7851333935212876620/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/10/get-started-with-tidymodels-and.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/7851333935212876620'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/7851333935212876620'/><link rel='alternate' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/10/get-started-with-tidymodels-and.html' title='Get started with tidymodels and classification of penguin data'/><author><name>José Ramón Cuesta</name><uri>http://www.blogger.com/profile/01637083082643255576</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/z57i2GVcdww/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2424328492215531658.post-4845289182542185496</id><published>2025-09-27T20:15:00.001+02:00</published><updated>2025-09-27T20:15:26.981+02:00</updated><title type='text'>Guía rápida para el uso de tidymodels</title><content type='html'>&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Interesante presentación en el grupo de usuarios de R de Madrid para el uso de modelos &quot;tidy&quot; a cargo de &lt;a href=&quot;https://www.linkedin.com/in/jes%C3%BAs-herranz-valera-4838295b/&quot; target=&quot;_blank&quot;&gt;Jesús Herranz Valera&lt;/a&gt;.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Podéis descargaros las presentación así como el código que se muestra en la misma desde &lt;a href=&quot;https://github.com/jesusherranz/Guia_Rapida_Uso_tidymodels&quot; target=&quot;_blank&quot;&gt;github&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgW684jWT08sh3NSDF2EWc-caGs1JvaDxW7vwzlTrRHBrCs6hwvAVM_TN59gkRLWtXfOSLb1eaKjQ6dx-_ekzaxjEM5UXgaOYV2eZhsgRqSoIrsq6AHoGsghztWvE0m8UFqj2Uhp_jekuKj4PLOQ-eTYEsE_V6stO5Iw7x-iUDt72QZgfsdeuEDHj-QT-aW&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;442&quot; data-original-width=&quot;798&quot; height=&quot;354&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgW684jWT08sh3NSDF2EWc-caGs1JvaDxW7vwzlTrRHBrCs6hwvAVM_TN59gkRLWtXfOSLb1eaKjQ6dx-_ekzaxjEM5UXgaOYV2eZhsgRqSoIrsq6AHoGsghztWvE0m8UFqj2Uhp_jekuKj4PLOQ-eTYEsE_V6stO5Iw7x-iUDt72QZgfsdeuEDHj-QT-aW=w640-h354&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Iremos comentando el uso de este tipo de modelos en próximos posts.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://nir-quimiometria.blogspot.com/feeds/4845289182542185496/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/09/guia-rapida-para-el-uso-de-tidymodels.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/4845289182542185496'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/4845289182542185496'/><link rel='alternate' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/09/guia-rapida-para-el-uso-de-tidymodels.html' title='Guía rápida para el uso de tidymodels'/><author><name>José Ramón Cuesta</name><uri>http://www.blogger.com/profile/01637083082643255576</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEgW684jWT08sh3NSDF2EWc-caGs1JvaDxW7vwzlTrRHBrCs6hwvAVM_TN59gkRLWtXfOSLb1eaKjQ6dx-_ekzaxjEM5UXgaOYV2eZhsgRqSoIrsq6AHoGsghztWvE0m8UFqj2Uhp_jekuKj4PLOQ-eTYEsE_V6stO5Iw7x-iUDt72QZgfsdeuEDHj-QT-aW=s72-w640-h354-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2424328492215531658.post-3700575542793716418</id><published>2025-06-27T17:22:00.005+02:00</published><updated>2025-06-27T17:22:53.513+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Soil Analysis"/><title type='text'>COMO INTERPRETAR ANÁLISIS DE SUELOS PARTE 1</title><content type='html'>&lt;div style=&quot;text-align: center;&quot;&gt;&lt;iframe frameborder=&quot;0&quot; height=&quot;270&quot; src=&quot;https://youtube.com/embed/LaLC5LeYYjk?si=ZcmaBsQjH364z_c4&quot; width=&quot;480&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://nir-quimiometria.blogspot.com/feeds/3700575542793716418/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/06/como-interpretar-analisis-de-suelos.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/3700575542793716418'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/3700575542793716418'/><link rel='alternate' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/06/como-interpretar-analisis-de-suelos.html' title='COMO INTERPRETAR ANÁLISIS DE SUELOS PARTE 1'/><author><name>José Ramón Cuesta</name><uri>http://www.blogger.com/profile/01637083082643255576</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/LaLC5LeYYjk/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2424328492215531658.post-7463182709972228140</id><published>2025-06-19T10:52:00.005+02:00</published><updated>2025-06-19T10:52:36.282+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="NIR Soil Analysis"/><title type='text'>Digital Soil Spectroscopy</title><content type='html'>&lt;div style=&quot;text-align: center;&quot;&gt;&lt;iframe frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;https://youtube.com/embed/ahk7FXdkPL4?si=beWFJOb5pUb50zXU&quot; width=&quot;480&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://nir-quimiometria.blogspot.com/feeds/7463182709972228140/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/06/digital-soil-spectroscopy.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/7463182709972228140'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/7463182709972228140'/><link rel='alternate' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/06/digital-soil-spectroscopy.html' title='Digital Soil Spectroscopy'/><author><name>José Ramón Cuesta</name><uri>http://www.blogger.com/profile/01637083082643255576</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/ahk7FXdkPL4/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2424328492215531658.post-3369287069271872930</id><published>2025-06-19T10:44:00.000+02:00</published><updated>2025-06-19T10:44:00.750+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Métodos de referencia"/><title type='text'>Determinación de fósforo en suelos (Método Olsen)</title><content type='html'>&lt;div style=&quot;text-align: center;&quot;&gt;&lt;iframe frameborder=&quot;0&quot; height=&quot;270&quot; src=&quot;https://youtube.com/embed/65xatQW0EKU?si=Gy4Oyz2CEdAguyEs&quot; width=&quot;480&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://nir-quimiometria.blogspot.com/feeds/3369287069271872930/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/06/determinacion-de-fosforo-en-suelos.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/3369287069271872930'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/3369287069271872930'/><link rel='alternate' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/06/determinacion-de-fosforo-en-suelos.html' title='Determinación de fósforo en suelos (Método Olsen)'/><author><name>José Ramón Cuesta</name><uri>http://www.blogger.com/profile/01637083082643255576</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/65xatQW0EKU/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2424328492215531658.post-4083806217531891087</id><published>2025-06-17T17:32:00.006+02:00</published><updated>2025-06-17T17:32:57.190+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="NIR Soil Analysis"/><title type='text'>Standard Normal Variate (SNV)</title><content type='html'>&lt;p style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;&lt;span style=&quot;background-color: white; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;As in previous posts, we are going to follow the&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a data-original-href=&quot;https://openknowledge.fao.org/items/512257df-e01a-4340-9a75-a64c4dd54ac1&quot; href=&quot;https://openknowledge.fao.org/items/512257df-e01a-4340-9a75-a64c4dd54ac1&quot; style=&quot;box-sizing: border-box; color: #2761e3; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px; text-underline-offset: 3px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Soil spectroscopy training material&lt;/em&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;background-color: white; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;and we are going to use the reference material provided.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;Let´s start loading the libraries and the data:&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb1&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb1-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb1-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb1-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;library&lt;/span&gt;(tidyverse)&lt;/span&gt;
&lt;span id=&quot;cb1-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb1-2&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb1-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;library&lt;/span&gt;(prospectr)&lt;/span&gt;
&lt;span id=&quot;cb1-3&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb1-3&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb1-3&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;load&lt;/span&gt;(&lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;C:/BLOG/Workspaces/NIR Soil Tutorial/post5.RData&quot;&lt;/span&gt;)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;In the training material we can read a clear explanation of what SNV does:&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;“Standard normal variate is a simple and widely used method that works by centering each individual spectrum to zero and then dividing each spectral band value by the standard deviation of the entire spectrum. The SNV method processes each observation independently. The disadvantage of SNV is that it can be sensitive to noise”.&lt;/em&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;So for each spectrum we calculate the mean of all data points reflectance values and also their standard deviation. Then we subtract for every data point the mean and divide the result by the standard deviation.&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;Using the prospectr package, we can use the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;standardNormalVariate&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;function to apply the SNV transformation to the spectra matrix.&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb2&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb2-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb2-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb2-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;snv_spectra &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;standardNormalVariate&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;Let´s use first classical R function matplot to plot the spectra before and after the SNV transformation:&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb3&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb3-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb3-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb3-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;matplot&lt;/span&gt;(&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;colnames&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc),&lt;/span&gt;
&lt;span id=&quot;cb3-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb3-2&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb3-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;t&lt;/span&gt;(snv_spectra),&lt;/span&gt;
&lt;span id=&quot;cb3-3&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb3-3&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb3-3&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;type =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;l&quot;&lt;/span&gt;,&lt;/span&gt;
&lt;span id=&quot;cb3-4&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb3-4&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb3-4&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;col =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;grey&quot;&lt;/span&gt;,&lt;/span&gt;
&lt;span id=&quot;cb3-5&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb3-5&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb3-5&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;lwd =&lt;/span&gt; &lt;span class=&quot;fl&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;0.5&lt;/span&gt;,&lt;/span&gt;
&lt;span id=&quot;cb3-6&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb3-6&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb3-6&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;xlab =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;Wavelength (nm)&quot;&lt;/span&gt;,&lt;/span&gt;
&lt;span id=&quot;cb3-7&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb3-7&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb3-7&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;ylab =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;Reflectance&quot;&lt;/span&gt;,&lt;/span&gt;
&lt;span id=&quot;cb3-8&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb3-8&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb3-8&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;main =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;Spectra after SNV&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb3-9&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb3-9&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb3-9&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;cell-output-display&quot; style=&quot;box-sizing: border-box; overflow-x: auto;&quot;&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;figure class=&quot;figure&quot; style=&quot;box-sizing: border-box; margin: 0px 0px 1rem;&quot;&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;img class=&quot;img-fluid figure-img&quot; src=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/index_files/figure-html/unnamed-chunk-3-1.png&quot; style=&quot;box-sizing: border-box; height: auto; line-height: 1; margin-bottom: 0.5rem; max-width: 100%; vertical-align: middle;&quot; width=&quot;672&quot; /&gt;&lt;/p&gt;&lt;/figure&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;Now with ggplot2:&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb4&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb4-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Create the long-format data frame for the different derivatives&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb4-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-2&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;snv_spectra_long &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;data.frame&lt;/span&gt;(&lt;/span&gt;
&lt;span id=&quot;cb4-3&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-3&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-3&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;sample =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rep&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;nrow&lt;/span&gt;(dat), &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;each =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ncol&lt;/span&gt;(snv_spectra)),&lt;/span&gt;
&lt;span id=&quot;cb4-4&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-4&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-4&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;oc =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rep&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;Organic_Carbon, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;each =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ncol&lt;/span&gt;(snv_spectra)),&lt;/span&gt;
&lt;span id=&quot;cb4-5&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-5&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-5&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;clay =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rep&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;Clay, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;each =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ncol&lt;/span&gt;(snv_spectra)),&lt;/span&gt;
&lt;span id=&quot;cb4-6&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-6&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-6&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;silt =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rep&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;Silt, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;each =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ncol&lt;/span&gt;(snv_spectra)),&lt;/span&gt;
&lt;span id=&quot;cb4-7&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-7&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-7&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;sand =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rep&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;Sand, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;each =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ncol&lt;/span&gt;(snv_spectra)),&lt;/span&gt;
&lt;span id=&quot;cb4-8&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-8&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-8&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;wavelength =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rep&lt;/span&gt;(my_wavelengths, &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;nrow&lt;/span&gt;(snv_spectra)),&lt;/span&gt;
&lt;span id=&quot;cb4-9&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-9&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-9&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;absorbance =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;as.vector&lt;/span&gt;(&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;t&lt;/span&gt;(snv_spectra))&lt;/span&gt;
&lt;span id=&quot;cb4-10&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-10&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-10&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;)&lt;/span&gt;
&lt;span id=&quot;cb4-11&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-11&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-11&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;/span&gt;
&lt;span id=&quot;cb4-12&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-12&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-12&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;/span&gt;
&lt;span id=&quot;cb4-13&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-13&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-13&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ggplot&lt;/span&gt;(snv_spectra_long, &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;aes&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;x =&lt;/span&gt; wavelength, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;y =&lt;/span&gt; absorbance, &lt;/span&gt;
&lt;span id=&quot;cb4-14&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-14&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-14&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;                             &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;group =&lt;/span&gt; sample, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;color =&lt;/span&gt; oc)) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb4-15&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-15&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-15&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;geom_line&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;alpha =&lt;/span&gt; &lt;span class=&quot;fl&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;0.5&lt;/span&gt;) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Set alpha to 0.5 for transparency&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb4-16&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-16&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-16&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;scale_color_gradient&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;low =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;blue&#39;&lt;/span&gt;, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;high =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;red&#39;&lt;/span&gt;) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb4-17&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-17&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-17&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;theme_minimal&lt;/span&gt;() &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb4-18&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-18&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#cb4-18&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;labs&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;x =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;Wavelength (nm)&#39;&lt;/span&gt;, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;y =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;Reflectance&#39;&lt;/span&gt;, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;color =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;Organic Carbon (%)&#39;&lt;/span&gt;)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;cell-output-display&quot; style=&quot;box-sizing: border-box; overflow-x: auto;&quot;&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;figure class=&quot;figure&quot; style=&quot;box-sizing: border-box; margin: 0px 0px 1rem;&quot;&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;img class=&quot;img-fluid figure-img&quot; src=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/index_files/figure-html/unnamed-chunk-4-1.png&quot; style=&quot;box-sizing: border-box; height: auto; line-height: 1; margin-bottom: 0.5rem; max-width: 100%; vertical-align: middle;&quot; width=&quot;672&quot; /&gt;&lt;/p&gt;&lt;/figure&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;section class=&quot;level3&quot; id=&quot;bibliography&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&lt;h3 class=&quot;anchored&quot; data-anchor-id=&quot;bibliography&quot; style=&quot;box-sizing: border-box; font-size: 1.45rem; line-height: 1.2; margin-bottom: 0.5rem; margin-top: 1.5rem; opacity: 0.9;&quot;&gt;Bibliography:&lt;a aria-label=&quot;Anchor&quot; class=&quot;anchorjs-link &quot; data-anchorjs-icon=&quot;&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Standard%20Normal%20Variate/#bibliography&quot; style=&quot;-webkit-font-smoothing: antialiased; background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #2761e3; font-family: anchorjs-icons; font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-size: 1em; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; font-weight: normal; line-height: 1; margin-left: 0.1875em; opacity: 0; padding-left: 0.1875em; padding-right: 0.1875em; text-decoration-line: none; text-underline-offset: 3px;&quot;&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;a data-original-href=&quot;https://openknowledge.fao.org/items/512257df-e01a-4340-9a75-a64c4dd54ac1&quot; href=&quot;https://openknowledge.fao.org/items/512257df-e01a-4340-9a75-a64c4dd54ac1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #2761e3; text-underline-offset: 3px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Soil spectroscopy training materia&lt;/em&gt;&lt;/span&gt;l&lt;/a&gt;&amp;nbsp;Wadoux, A., Ramirez-Lopez, L., Ge, Y., Barra, I. &amp;amp; Peng, Y. 2025. A course on applied data analytics for soil analysis with infrared spectroscopy – Soil spectroscopy training manual 2. Rome, FAO.&lt;/p&gt;&lt;/section&gt;</content><link rel='replies' type='application/atom+xml' href='http://nir-quimiometria.blogspot.com/feeds/4083806217531891087/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/06/standard-normal-variate-snv.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/4083806217531891087'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/4083806217531891087'/><link rel='alternate' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/06/standard-normal-variate-snv.html' title='Standard Normal Variate (SNV)'/><author><name>José Ramón Cuesta</name><uri>http://www.blogger.com/profile/01637083082643255576</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2424328492215531658.post-388120361282019062</id><published>2025-06-13T17:04:00.007+02:00</published><updated>2025-06-13T17:04:44.162+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="NIR Soil Analysis"/><title type='text'>NIR Chemometrics for soil analysis</title><content type='html'>&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;blockquote style=&quot;border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: center;&quot;&gt;&lt;iframe allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&quot; allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; referrerpolicy=&quot;strict-origin-when-cross-origin&quot; src=&quot;https://www.youtube.com/embed/-X2aSwNnNvY?si=q13f9VFlPmh87rY1&quot; title=&quot;YouTube video player&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://nir-quimiometria.blogspot.com/feeds/388120361282019062/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/06/nir-chemometrics-for-soil-analysis.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/388120361282019062'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/388120361282019062'/><link rel='alternate' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/06/nir-chemometrics-for-soil-analysis.html' title='NIR Chemometrics for soil analysis'/><author><name>José Ramón Cuesta</name><uri>http://www.blogger.com/profile/01637083082643255576</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/-X2aSwNnNvY/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2424328492215531658.post-4901710013072679300</id><published>2025-06-11T16:15:00.005+02:00</published><updated>2025-06-11T16:15:52.582+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="NIR Soil Analysis"/><title type='text'>Adding noise to the spectra</title><content type='html'>&lt;p style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;&lt;span style=&quot;background-color: white; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;We have seen in the previous post how to remove artifacts in the spectra using the&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;spliceCorrection&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;function from the&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;prospectr&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;package. But there are other sources of noise in the spectra which depends of several factors, as the quality of the spectrophotometer (can use a signal to noise ratio meassurement to test it), the scanning time, resolution, sample presentation, …. In this post we continue with the “course on applied data analytics for soil analysis with infrared spectroscopy” using the reference material provided. And this time we are going to see the part of the course where we add noise to the spectra and then we apply two methods to remove it. The methods are the&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Moving Window Average&lt;/em&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;and the&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Savitzky-Golay Filter&lt;/em&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;First we load the libraries we are going to use:&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb1&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb1-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb1-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb1-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;library&lt;/span&gt;(tidyverse)&lt;/span&gt;
&lt;span id=&quot;cb1-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb1-2&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb1-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;load&lt;/span&gt;(&lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;C:/BLOG/Workspaces/NIR Soil Tutorial/post4.RData&quot;&lt;/span&gt;)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;section class=&quot;level3&quot; id=&quot;adding-noise-to-the-first-spectrum&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&lt;h3 class=&quot;anchored&quot; data-anchor-id=&quot;adding-noise-to-the-first-spectrum&quot; style=&quot;box-sizing: border-box; font-size: 1.45rem; line-height: 1.2; margin-bottom: 0.5rem; margin-top: 1.5rem; opacity: 0.9;&quot;&gt;Adding noise to the first spectrum&lt;a aria-label=&quot;Anchor&quot; class=&quot;anchorjs-link &quot; data-anchorjs-icon=&quot;&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#adding-noise-to-the-first-spectrum&quot; style=&quot;-webkit-font-smoothing: antialiased; background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #2761e3; font-family: anchorjs-icons; font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-size: 1em; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; font-weight: normal; line-height: 1; margin-left: 0.1875em; opacity: 0; padding-left: 0.1875em; padding-right: 0.1875em; text-decoration-line: none; text-underline-offset: 3px;&quot;&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;We create some Gaussian noise to the first spectrum in the dataset (mean = 0, standard deviation = 0.0025), and we are gong to add it to the first spectrum in the dataset. Take in account that we are going to select the dataset dat$spc, which is the one we created in the previous post, so we are going to use the spectra without the artifacts.&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb2&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb2-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb2-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb2-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;#Set a seed for reproducibility of random noise&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb2-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb2-2&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb2-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;set.seed&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;801124&lt;/span&gt;)&lt;/span&gt;
&lt;span id=&quot;cb2-3&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb2-3&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb2-3&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Add random noise to the first sample’s spectrum&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb2-4&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb2-4&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb2-4&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;my_noisy_spc &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc[&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1&lt;/span&gt;, ] &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rnorm&lt;/span&gt;(&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ncol&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc), &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;sd =&lt;/span&gt; &lt;span class=&quot;fl&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;0.0025&lt;/span&gt;)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;If we just want to se the noise that we are adding:&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb3&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb3-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb3-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb3-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ggplot&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;data =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;data.frame&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;wavelength =&lt;/span&gt; my_wavelengths, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;absorbance =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rnorm&lt;/span&gt;(&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ncol&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc), &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;sd =&lt;/span&gt; &lt;span class=&quot;fl&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;0.0025&lt;/span&gt;)),&lt;/span&gt;
&lt;span id=&quot;cb3-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb3-2&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb3-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;       &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;aes&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;x =&lt;/span&gt; wavelength, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;y =&lt;/span&gt; absorbance)) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb3-3&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb3-3&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb3-3&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;geom_line&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;color =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;blue&quot;&lt;/span&gt;) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb3-4&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb3-4&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb3-4&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;labs&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;title =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;Noisy Spectrum&quot;&lt;/span&gt;,&lt;/span&gt;
&lt;span id=&quot;cb3-5&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb3-5&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb3-5&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;       &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;x =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;Wavelength (nm)&quot;&lt;/span&gt;,&lt;/span&gt;
&lt;span id=&quot;cb3-6&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb3-6&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb3-6&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;       &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;y =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;Absorbance&quot;&lt;/span&gt;) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb3-7&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb3-7&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb3-7&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;theme_minimal&lt;/span&gt;()&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;cell-output-display&quot; style=&quot;box-sizing: border-box; overflow-x: auto;&quot;&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;figure class=&quot;figure&quot; style=&quot;box-sizing: border-box; margin: 0px 0px 1rem;&quot;&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;img class=&quot;img-fluid figure-img&quot; src=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/index_files/figure-html/unnamed-chunk-3-1.png&quot; style=&quot;box-sizing: border-box; height: auto; line-height: 1; margin-bottom: 0.5rem; max-width: 100%; vertical-align: middle;&quot; width=&quot;672&quot; /&gt;&lt;/p&gt;&lt;/figure&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;level3&quot; id=&quot;plotting-the-noisy-spectrum&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&lt;h3 class=&quot;anchored&quot; data-anchor-id=&quot;plotting-the-noisy-spectrum&quot; style=&quot;box-sizing: border-box; font-size: 1.45rem; line-height: 1.2; margin-bottom: 0.5rem; margin-top: 1.5rem; opacity: 0.9;&quot;&gt;Plotting the noisy spectrum&lt;a aria-label=&quot;Anchor&quot; class=&quot;anchorjs-link &quot; data-anchorjs-icon=&quot;&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#plotting-the-noisy-spectrum&quot; style=&quot;-webkit-font-smoothing: antialiased; background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #2761e3; font-family: anchorjs-icons; font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-size: 1em; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; font-weight: normal; line-height: 1; margin-left: 0.1875em; opacity: 0; padding-left: 0.1875em; padding-right: 0.1875em; text-decoration-line: none; text-underline-offset: 3px;&quot;&gt;&lt;/a&gt;&lt;/h3&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb4&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb4-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb4-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb4-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ggplot&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;data =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;data.frame&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;wavelength =&lt;/span&gt; my_wavelengths, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;absorbance =&lt;/span&gt; my_noisy_spc),&lt;/span&gt;
&lt;span id=&quot;cb4-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb4-2&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb4-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;       &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;aes&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;x =&lt;/span&gt; wavelength, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;y =&lt;/span&gt; absorbance)) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb4-3&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb4-3&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb4-3&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;geom_line&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;color =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;blue&quot;&lt;/span&gt;) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb4-4&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb4-4&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb4-4&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;labs&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;title =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;Spectrum 1 with added Noise&quot;&lt;/span&gt;,&lt;/span&gt;
&lt;span id=&quot;cb4-5&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb4-5&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb4-5&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;       &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;x =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;Wavelength (nm)&quot;&lt;/span&gt;,&lt;/span&gt;
&lt;span id=&quot;cb4-6&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb4-6&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb4-6&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;       &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;y =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;Absorbance&quot;&lt;/span&gt;) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb4-7&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb4-7&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb4-7&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;theme_minimal&lt;/span&gt;()&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;cell-output-display&quot; style=&quot;box-sizing: border-box; overflow-x: auto;&quot;&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;figure class=&quot;figure&quot; style=&quot;box-sizing: border-box; margin: 0px 0px 1rem;&quot;&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;img class=&quot;img-fluid figure-img&quot; src=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/index_files/figure-html/unnamed-chunk-4-1.png&quot; style=&quot;box-sizing: border-box; height: auto; line-height: 1; margin-bottom: 0.5rem; max-width: 100%; vertical-align: middle;&quot; width=&quot;672&quot; /&gt;&lt;/p&gt;&lt;/figure&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;level3&quot; id=&quot;removing-the-noise&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&lt;h3 class=&quot;anchored&quot; data-anchor-id=&quot;removing-the-noise&quot; style=&quot;box-sizing: border-box; font-size: 1.45rem; line-height: 1.2; margin-bottom: 0.5rem; margin-top: 1.5rem; opacity: 0.9;&quot;&gt;Removing the noise&lt;a aria-label=&quot;Anchor&quot; class=&quot;anchorjs-link &quot; data-anchorjs-icon=&quot;&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#removing-the-noise&quot; style=&quot;-webkit-font-smoothing: antialiased; background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #2761e3; font-family: anchorjs-icons; font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-size: 1em; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; font-weight: normal; line-height: 1; margin-left: 0.1875em; opacity: 0; padding-left: 0.1875em; padding-right: 0.1875em; text-decoration-line: none; text-underline-offset: 3px;&quot;&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;No let´s apply to this spectrum two methods used to remove noise:&lt;/p&gt;&lt;/section&gt;&lt;section class=&quot;level3&quot; id=&quot;moving-window-average&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&lt;h3 class=&quot;anchored&quot; data-anchor-id=&quot;moving-window-average&quot; style=&quot;box-sizing: border-box; font-size: 1.45rem; line-height: 1.2; margin-bottom: 0.5rem; margin-top: 1.5rem; opacity: 0.9;&quot;&gt;Moving Window Average&lt;a aria-label=&quot;Anchor&quot; class=&quot;anchorjs-link &quot; data-anchorjs-icon=&quot;&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#moving-window-average&quot; style=&quot;-webkit-font-smoothing: antialiased; background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #2761e3; font-family: anchorjs-icons; font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-size: 1em; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; font-weight: normal; line-height: 1; margin-left: 0.1875em; opacity: 0; padding-left: 0.1875em; padding-right: 0.1875em; text-decoration-line: none; text-underline-offset: 3px;&quot;&gt;&lt;/a&gt;&lt;/h3&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb5&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb5-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb5-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb5-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;library&lt;/span&gt;(prospectr)&lt;/span&gt;
&lt;span id=&quot;cb5-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb5-2&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb5-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Replace ‘my_noisy_spc’ with your actual data frame or matrix and ‘w’ with the desired&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb5-3&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb5-3&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb5-3&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# window size&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb5-4&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb5-4&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb5-4&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;mwa_result &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;movav&lt;/span&gt;(my_noisy_spc, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;w =&lt;/span&gt; &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;11&lt;/span&gt;)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;level3&quot; id=&quot;savitzky-golay-filter&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&lt;h3 class=&quot;anchored&quot; data-anchor-id=&quot;savitzky-golay-filter&quot; style=&quot;box-sizing: border-box; font-size: 1.45rem; line-height: 1.2; margin-bottom: 0.5rem; margin-top: 1.5rem; opacity: 0.9;&quot;&gt;Savitzky-Golay Filter&lt;a aria-label=&quot;Anchor&quot; class=&quot;anchorjs-link &quot; data-anchorjs-icon=&quot;&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#savitzky-golay-filter&quot; style=&quot;-webkit-font-smoothing: antialiased; background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #2761e3; font-family: anchorjs-icons; font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-size: 1em; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; font-weight: normal; line-height: 1; margin-left: 0.1875em; opacity: 0; padding-left: 0.1875em; padding-right: 0.1875em; text-decoration-line: none; text-underline-offset: 3px;&quot;&gt;&lt;/a&gt;&lt;/h3&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb6&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb6-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb6-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb6-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Replace ‘my_noisy_spc’ with your actual data frame or matrix, ‘m’ with the window size,&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb6-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb6-2&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb6-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# and ‘p’ with the polynomial order&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb6-3&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb6-3&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb6-3&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;sg_result &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;savitzkyGolay&lt;/span&gt;(&lt;/span&gt;
&lt;span id=&quot;cb6-4&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb6-4&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb6-4&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;my_noisy_spc, &lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# the noisy spectrum&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb6-5&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb6-5&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb6-5&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;m =&lt;/span&gt; &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# this m is for the derivative order, 0 is for no derivative&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb6-6&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb6-6&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb6-6&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;p =&lt;/span&gt; &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;3&lt;/span&gt;, &lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# the polynomial order&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb6-7&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb6-7&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb6-7&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;w =&lt;/span&gt; &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;11&lt;/span&gt; &lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# the window size&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb6-8&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb6-8&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb6-8&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb7&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb7-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Create a long-format data frame for the MVA spectrum&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb7-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-2&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;long_mwa_spc &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;data.frame&lt;/span&gt;(&lt;/span&gt;
&lt;span id=&quot;cb7-3&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-3&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-3&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;wavelength =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;as.numeric&lt;/span&gt;(&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;names&lt;/span&gt;(mwa_result)), &lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Extract the wavelengths&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb7-4&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-4&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-4&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;spectral_value =&lt;/span&gt; mwa_result, &lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Store the spectral values from the MVA&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb7-5&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-5&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-5&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;method =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;mva&#39;&lt;/span&gt; &lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Label the data&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb7-6&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-6&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-6&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;)&lt;/span&gt;
&lt;span id=&quot;cb7-7&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-7&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-7&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Create a long-format data frame for the Savitzky-Golay (SG) spectrum&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb7-8&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-8&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-8&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;long_sg_spc &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;data.frame&lt;/span&gt;(&lt;/span&gt;
&lt;span id=&quot;cb7-9&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-9&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-9&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;wavelength =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;as.numeric&lt;/span&gt;(&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;names&lt;/span&gt;(sg_result)), &lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Extract the wavelengths&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb7-10&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-10&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-10&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;spectral_value =&lt;/span&gt; sg_result, &lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Store the spectral values from the SG&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb7-11&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-11&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-11&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;method =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;sg&#39;&lt;/span&gt; &lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Label the data&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb7-12&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-12&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-12&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;)&lt;/span&gt;
&lt;span id=&quot;cb7-13&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-13&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-13&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Combine the long-format MVA and SG data frames into one&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb7-14&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-14&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb7-14&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;denoised_long &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rbind&lt;/span&gt;(long_mwa_spc, long_sg_spc)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;Now we create a data frame for the original noisy spectrum and some labels.&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb8&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb8-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb8-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb8-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Create a data frame for the original noisy spectrum&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb8-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb8-2&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb8-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;original_noisy &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;data.frame&lt;/span&gt;(&lt;/span&gt;
&lt;span id=&quot;cb8-3&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb8-3&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb8-3&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;wavelength =&lt;/span&gt; my_wavelengths, &lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Use the original wavelengths&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb8-4&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb8-4&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb8-4&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;spectral_value =&lt;/span&gt; my_noisy_spc &lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Use the original noisy spectrum values&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb8-5&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb8-5&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb8-5&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;)&lt;/span&gt;
&lt;span id=&quot;cb8-6&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb8-6&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb8-6&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;/span&gt;
&lt;span id=&quot;cb8-7&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb8-7&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb8-7&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;my_labels &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;c&lt;/span&gt;(&lt;/span&gt;
&lt;span id=&quot;cb8-8&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb8-8&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb8-8&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;mva&#39;&lt;/span&gt; &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;Moving average smoothing&#39;&lt;/span&gt;,&lt;/span&gt;
&lt;span id=&quot;cb8-9&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb8-9&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb8-9&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;sg&#39;&lt;/span&gt; &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;Savitzky-Golay filtering&#39;&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb8-10&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb8-10&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb8-10&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;Now we want to overplot the corrected spectra over the noisy one:&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb9&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb9-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Plot the spectra using ggplot2&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb9-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-2&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ggplot&lt;/span&gt;() &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb9-3&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-3&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-3&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Plot the original noisy spectrum as a red line in the background&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb9-4&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-4&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-4&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;geom_line&lt;/span&gt;(&lt;/span&gt;
&lt;span id=&quot;cb9-5&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-5&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-5&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;data =&lt;/span&gt; original_noisy,&lt;/span&gt;
&lt;span id=&quot;cb9-6&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-6&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-6&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;aes&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;x =&lt;/span&gt; wavelength, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;y =&lt;/span&gt; spectral_value),&lt;/span&gt;
&lt;span id=&quot;cb9-7&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-7&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-7&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;color =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;black&#39;&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb9-8&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-8&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-8&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb9-9&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-9&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-9&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Plot the MVA and SG processed spectra on top of the original noisy spectrum&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb9-10&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-10&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-10&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;geom_line&lt;/span&gt;(&lt;/span&gt;
&lt;span id=&quot;cb9-11&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-11&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-11&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;data =&lt;/span&gt; denoised_long,&lt;/span&gt;
&lt;span id=&quot;cb9-12&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-12&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-12&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;aes&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;x =&lt;/span&gt; wavelength, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;y =&lt;/span&gt; spectral_value, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;color =&lt;/span&gt; method, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;group =&lt;/span&gt; method)&lt;/span&gt;
&lt;span id=&quot;cb9-13&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-13&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-13&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb9-14&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-14&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-14&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Add titles and labels for the axes&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb9-15&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-15&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-15&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;labs&lt;/span&gt;(&lt;/span&gt;
&lt;span id=&quot;cb9-16&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-16&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-16&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;x =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;Wavelength (nm)&#39;&lt;/span&gt;,&lt;/span&gt;
&lt;span id=&quot;cb9-17&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-17&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-17&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;y =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;Reflectance&#39;&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb9-18&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-18&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-18&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb9-19&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-19&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-19&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;#coord_cartesian(xlim = c(1500, 1800), ylim = c(0.425, 0.450)) +&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb9-20&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-20&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-20&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Manually set the colors for the MVA and SG lines&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb9-21&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-21&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-21&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;scale_color_manual&lt;/span&gt;(&lt;/span&gt;
&lt;span id=&quot;cb9-22&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-22&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-22&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;values =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;c&lt;/span&gt;(&lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;mva&#39;&lt;/span&gt; &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;#00AFBB&#39;&lt;/span&gt;, &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;sg&#39;&lt;/span&gt; &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;#E7B800&#39;&lt;/span&gt;),&lt;/span&gt;
&lt;span id=&quot;cb9-23&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-23&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-23&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;labels =&lt;/span&gt; my_labels&lt;/span&gt;
&lt;span id=&quot;cb9-24&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-24&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-24&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb9-25&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-25&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-25&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Facet the plot by the method, creating separate plots for MVA and SG&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb9-26&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-26&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-26&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;facet_grid&lt;/span&gt;(. &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;~&lt;/span&gt; method, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;labeller =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;labeller&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;method =&lt;/span&gt; my_labels)) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb9-27&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-27&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb9-27&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;theme&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;legend.position =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;top&#39;&lt;/span&gt;) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;guides&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;color =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;guide_legend&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;title =&lt;/span&gt; &lt;span class=&quot;cn&quot; style=&quot;box-sizing: border-box; color: #8f5902; font-style: inherit;&quot;&gt;NULL&lt;/span&gt;))&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;cell-output-display&quot; style=&quot;box-sizing: border-box; overflow-x: auto;&quot;&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;figure class=&quot;figure&quot; style=&quot;box-sizing: border-box; margin: 0px 0px 1rem;&quot;&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;img class=&quot;img-fluid figure-img&quot; src=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/index_files/figure-html/unnamed-chunk-9-1.png&quot; style=&quot;box-sizing: border-box; height: auto; line-height: 1; margin-bottom: 0.5rem; max-width: 100%; vertical-align: middle;&quot; width=&quot;672&quot; /&gt;&lt;/p&gt;&lt;/figure&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;We can zoom the spectra to see the differences more clearly:&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb10&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb10-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ggplot&lt;/span&gt;() &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb10-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-2&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Plot the original noisy spectrum as a red line in the background&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb10-3&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-3&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-3&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;geom_line&lt;/span&gt;(&lt;/span&gt;
&lt;span id=&quot;cb10-4&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-4&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-4&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;data =&lt;/span&gt; original_noisy,&lt;/span&gt;
&lt;span id=&quot;cb10-5&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-5&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-5&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;aes&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;x =&lt;/span&gt; wavelength, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;y =&lt;/span&gt; spectral_value),&lt;/span&gt;
&lt;span id=&quot;cb10-6&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-6&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-6&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;color =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;black&#39;&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb10-7&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-7&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-7&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb10-8&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-8&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-8&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Plot the MVA and SG processed spectra on top of the original noisy spectrum&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb10-9&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-9&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-9&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;geom_line&lt;/span&gt;(&lt;/span&gt;
&lt;span id=&quot;cb10-10&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-10&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-10&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;data =&lt;/span&gt; denoised_long,&lt;/span&gt;
&lt;span id=&quot;cb10-11&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-11&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-11&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;aes&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;x =&lt;/span&gt; wavelength, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;y =&lt;/span&gt; spectral_value, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;color =&lt;/span&gt; method, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;group =&lt;/span&gt; method), &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;size =&lt;/span&gt; &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb10-12&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-12&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-12&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb10-13&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-13&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-13&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Add titles and labels for the axes&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb10-14&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-14&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-14&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;labs&lt;/span&gt;(&lt;/span&gt;
&lt;span id=&quot;cb10-15&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-15&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-15&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;x =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;Wavelength (nm)&#39;&lt;/span&gt;,&lt;/span&gt;
&lt;span id=&quot;cb10-16&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-16&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-16&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;y =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;Reflectance&#39;&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb10-17&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-17&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-17&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb10-18&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-18&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-18&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;coord_cartesian&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;xlim =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;c&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1500&lt;/span&gt;, &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1800&lt;/span&gt;), &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;ylim =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;c&lt;/span&gt;(&lt;span class=&quot;fl&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;0.425&lt;/span&gt;, &lt;span class=&quot;fl&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;0.450&lt;/span&gt;)) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb10-19&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-19&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-19&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Manually set the colors for the MVA and SG lines&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb10-20&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-20&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-20&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;scale_color_manual&lt;/span&gt;(&lt;/span&gt;
&lt;span id=&quot;cb10-21&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-21&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-21&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;values =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;c&lt;/span&gt;(&lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;mva&#39;&lt;/span&gt; &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;#00AFBB&#39;&lt;/span&gt;, &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;sg&#39;&lt;/span&gt; &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;#E7B800&#39;&lt;/span&gt;),&lt;/span&gt;
&lt;span id=&quot;cb10-22&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-22&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-22&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;labels =&lt;/span&gt; my_labels&lt;/span&gt;
&lt;span id=&quot;cb10-23&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-23&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-23&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb10-24&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-24&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-24&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Facet the plot by the method, creating separate plots for MVA and SG&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb10-25&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-25&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-25&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;facet_grid&lt;/span&gt;(. &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;~&lt;/span&gt; method, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;labeller =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;labeller&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;method =&lt;/span&gt; my_labels)) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb10-26&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-26&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#cb10-26&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;theme&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;legend.position =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;top&#39;&lt;/span&gt;) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;guides&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;color =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;guide_legend&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;title =&lt;/span&gt; &lt;span class=&quot;cn&quot; style=&quot;box-sizing: border-box; color: #8f5902; font-style: inherit;&quot;&gt;NULL&lt;/span&gt;))&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;cell-output cell-output-stderr&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;pre style=&quot;background-color: initial; border: initial; box-sizing: border-box; color: black; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 1rem; margin-top: 0px; overflow: auto; padding: initial;&quot;&gt;&lt;code style=&quot;background-color: initial; box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; padding: 0.125rem 0.25rem; word-break: normal;&quot;&gt;&lt;img class=&quot;img-fluid figure-img&quot; src=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/index_files/figure-html/unnamed-chunk-10-1.png&quot; style=&quot;box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px; height: auto; line-height: 1; margin-bottom: 0.5rem; max-width: 100%; vertical-align: middle;&quot; width=&quot;672&quot; /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;level3&quot; id=&quot;bibliography&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&lt;h3 class=&quot;anchored&quot; data-anchor-id=&quot;bibliography&quot; style=&quot;box-sizing: border-box; font-size: 1.45rem; line-height: 1.2; margin-bottom: 0.5rem; margin-top: 1.5rem; opacity: 0.9;&quot;&gt;Bibliography:&lt;a aria-label=&quot;Anchor&quot; class=&quot;anchorjs-link &quot; data-anchorjs-icon=&quot;&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Adding%20noise%20to%20the%20spectra/#bibliography&quot; style=&quot;-webkit-font-smoothing: antialiased; background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #2761e3; font-family: anchorjs-icons; font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-size: 1em; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; font-weight: normal; line-height: 1; margin-left: 0.1875em; opacity: 0; padding-left: 0.1875em; padding-right: 0.1875em; text-decoration-line: none; text-underline-offset: 3px;&quot;&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;a data-original-href=&quot;https://openknowledge.fao.org/items/512257df-e01a-4340-9a75-a64c4dd54ac1&quot; href=&quot;https://openknowledge.fao.org/items/512257df-e01a-4340-9a75-a64c4dd54ac1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #2761e3; text-underline-offset: 3px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Soil spectroscopy training materia&lt;/em&gt;&lt;/span&gt;l&lt;/a&gt;&amp;nbsp;Wadoux, A., Ramirez-Lopez, L., Ge, Y., Barra, I. &amp;amp; Peng, Y. 2025. A course on applied data analytics for soil analysis with infrared spectroscopy – Soil spectroscopy training manual 2. Rome, FAO.&lt;/p&gt;&lt;/section&gt;</content><link rel='replies' type='application/atom+xml' href='http://nir-quimiometria.blogspot.com/feeds/4901710013072679300/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/06/adding-noise-to-spectra.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/4901710013072679300'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/4901710013072679300'/><link rel='alternate' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/06/adding-noise-to-spectra.html' title='Adding noise to the spectra'/><author><name>José Ramón Cuesta</name><uri>http://www.blogger.com/profile/01637083082643255576</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2424328492215531658.post-3831860344040275654</id><published>2025-06-09T12:08:00.000+02:00</published><updated>2025-06-09T12:08:04.066+02:00</updated><title type='text'>Removing the artifacts in the spectra</title><content type='html'>&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;To follow this post, remember than in the first post we build a matrix with the raw NIR spectra, and that matrix is the one we are going to treat in this post to remove the spectra so we will give to the new matrix (without the artifacts). This will be the first of several conversions of the spsectra matris where we continue applying other math treatments.&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;First we load the libraries we are going to use and the data we prepared in the previous post:&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb1&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb1-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb1-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb1-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;library&lt;/span&gt;(tidyverse)&lt;/span&gt;
&lt;span id=&quot;cb1-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb1-2&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb1-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;library&lt;/span&gt;(prospectr)&lt;/span&gt;
&lt;span id=&quot;cb1-3&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb1-3&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb1-3&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;load&lt;/span&gt;(&lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;C:/BLOG/Workspaces/NIR Soil Tutorial/post2.RData&quot;&lt;/span&gt;)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;The function we are going to use is&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;spliceCorrection&lt;/em&gt;&lt;/span&gt;&amp;nbsp;from the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;prospectr&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;package. This function is used to correct the spectra for artifacts due to detector changes or other reasons. The function takes as input a matrix of spectra and returns a corrected matrix of spectra. To find information:&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb2&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb2-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb2-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb2-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;?prospectr&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;::&lt;/span&gt;spliceCorrection&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;cell&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb3&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb3-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb3-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb3-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;spliceCorrection&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc_raw, my_wavelengths, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;splice =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;c&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1000&lt;/span&gt;, &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1830&lt;/span&gt;))&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;And now we create a long version of the dataframe to plot it with ggplot2, as we have done in the second post:&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb4&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb4-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;spc_long &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;data.frame&lt;/span&gt;(&lt;/span&gt;
&lt;span id=&quot;cb4-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-2&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;sample =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rep&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;nrow&lt;/span&gt;(dat), &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;each =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ncol&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc)),&lt;/span&gt;
&lt;span id=&quot;cb4-3&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-3&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-3&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;oc =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rep&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;Organic_Carbon, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;each =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ncol&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc)),&lt;/span&gt;
&lt;span id=&quot;cb4-4&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-4&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-4&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;clay =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rep&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;Clay, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;each =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ncol&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc)),&lt;/span&gt;
&lt;span id=&quot;cb4-5&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-5&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-5&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;silt =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rep&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;Silt, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;each =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ncol&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc)),&lt;/span&gt;
&lt;span id=&quot;cb4-6&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-6&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-6&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;sand =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rep&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;Sand, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;each =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ncol&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc)),&lt;/span&gt;
&lt;span id=&quot;cb4-7&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-7&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-7&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;wavelength =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rep&lt;/span&gt;(my_wavelengths, &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;nrow&lt;/span&gt;(dat)),&lt;/span&gt;
&lt;span id=&quot;cb4-8&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-8&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-8&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;absorbance =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;as.vector&lt;/span&gt;(&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;t&lt;/span&gt;(&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;log&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;/&lt;/span&gt; dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc, &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;10&lt;/span&gt;))))&lt;/span&gt;
&lt;span id=&quot;cb4-9&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-9&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-9&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;/span&gt;
&lt;span id=&quot;cb4-10&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-10&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-10&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;/span&gt;
&lt;span id=&quot;cb4-11&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-11&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-11&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ggplot&lt;/span&gt;(&lt;/span&gt;
&lt;span id=&quot;cb4-12&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-12&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-12&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;spc_long,&lt;/span&gt;
&lt;span id=&quot;cb4-13&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-13&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-13&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;aes&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;x =&lt;/span&gt; wavelength, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;y =&lt;/span&gt; absorbance, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;group =&lt;/span&gt; sample, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;color =&lt;/span&gt; oc)) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb4-14&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-14&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-14&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;geom_line&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;alpha =&lt;/span&gt; &lt;span class=&quot;fl&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;0.5&lt;/span&gt;) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Set alpha to 0.5 for transparency&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb4-15&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-15&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-15&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;scale_color_gradient&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;low =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;blue&#39;&lt;/span&gt;, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;high =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;red&#39;&lt;/span&gt;) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb4-16&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-16&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-16&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;theme_minimal&lt;/span&gt;() &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb4-17&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-17&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-17&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;labs&lt;/span&gt;(&lt;/span&gt;
&lt;span id=&quot;cb4-18&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-18&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-18&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;x =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;Wavelength (nm)&#39;&lt;/span&gt;,&lt;/span&gt;
&lt;span id=&quot;cb4-19&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-19&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-19&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;y =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;Reflectance&#39;&lt;/span&gt;,&lt;/span&gt;
&lt;span id=&quot;cb4-20&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-20&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-20&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;color =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;Organic Carbon (%)&#39;&lt;/span&gt;) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb4-21&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-21&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb4-21&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;theme&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;legend.position =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;top&#39;&lt;/span&gt;)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;cell-output-display&quot; style=&quot;box-sizing: border-box; overflow-x: auto;&quot;&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;figure class=&quot;figure&quot; style=&quot;box-sizing: border-box; margin: 0px 0px 1rem;&quot;&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;img class=&quot;img-fluid figure-img&quot; src=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/index_files/figure-html/unnamed-chunk-4-1.png&quot; style=&quot;box-sizing: border-box; height: auto; line-height: 1; margin-bottom: 0.5rem; max-width: 100%; vertical-align: middle;&quot; width=&quot;672&quot; /&gt;&lt;/p&gt;&lt;/figure&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;Now we can check if the artifacts are removed:&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb5&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb5-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb5-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb5-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ggplot&lt;/span&gt;(spc_long,&lt;/span&gt;
&lt;span id=&quot;cb5-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb5-2&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb5-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;       &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;aes&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;x =&lt;/span&gt; wavelength, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;y =&lt;/span&gt; absorbance, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;group =&lt;/span&gt; sample)) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb5-3&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb5-3&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb5-3&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;geom_line&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;alpha =&lt;/span&gt; &lt;span class=&quot;fl&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;0.5&lt;/span&gt;) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb5-4&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb5-4&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb5-4&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;theme_minimal&lt;/span&gt;() &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb5-5&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb5-5&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb5-5&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;labs&lt;/span&gt;(&lt;/span&gt;
&lt;span id=&quot;cb5-6&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb5-6&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb5-6&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;    &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;title =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;Artifacts at 1000 nm removed&quot;&lt;/span&gt;,&lt;/span&gt;
&lt;span id=&quot;cb5-7&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb5-7&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb5-7&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;    &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;x =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;Wavelength (nm)&#39;&lt;/span&gt;,&lt;/span&gt;
&lt;span id=&quot;cb5-8&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb5-8&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb5-8&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;    &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;y =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;Reflectance&#39;&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb5-9&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb5-9&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb5-9&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  ) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb5-10&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb5-10&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb5-10&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;coord_cartesian&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;xlim =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;c&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;990&lt;/span&gt;, &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1010&lt;/span&gt;), &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;ylim =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;c&lt;/span&gt;(&lt;span class=&quot;fl&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;0.4&lt;/span&gt;, &lt;span class=&quot;fl&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;0.45&lt;/span&gt;)) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb5-11&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb5-11&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/#cb5-11&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;geom_vline&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;xintercept =&lt;/span&gt; &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1000&lt;/span&gt;, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;linetype =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;dashed&quot;&lt;/span&gt;, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;color =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;red&quot;&lt;/span&gt;)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;img class=&quot;img-fluid figure-img&quot; src=&quot;https://nir-chemometrics.netlify.app/posts/Removing%20the%20artifacts%20in%20the%20spectrum/index_files/figure-html/unnamed-chunk-5-1.png&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px; height: auto; line-height: 1; margin-bottom: 0.5rem; max-width: 100%; vertical-align: middle;&quot; width=&quot;672&quot; /&gt;&amp;nbsp;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://nir-quimiometria.blogspot.com/feeds/3831860344040275654/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/06/removing-artifacts-in-spectra.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/3831860344040275654'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/3831860344040275654'/><link rel='alternate' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/06/removing-artifacts-in-spectra.html' title='Removing the artifacts in the spectra'/><author><name>José Ramón Cuesta</name><uri>http://www.blogger.com/profile/01637083082643255576</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2424328492215531658.post-7757470945176521819</id><published>2025-05-31T20:21:00.006+02:00</published><updated>2025-05-31T20:40:03.225+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="NIR Soil Analysis"/><title type='text'>Looking for artifacts in the spectra</title><content type='html'>&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&amp;nbsp;&lt;span style=&quot;background-color: white; color: #343a40; font-size: 17px;&quot;&gt;In this post we are going to look to the NIR spectra in detail looking for artifacts in the sample:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;section class=&quot;level3&quot; id=&quot;plotting-the-spectra&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-size: 17px;&quot;&gt;&lt;h3 class=&quot;anchored&quot; data-anchor-id=&quot;plotting-the-spectra&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 1.45rem; line-height: 1.2; margin-bottom: 0.5rem; margin-top: 1.5rem; opacity: 0.9;&quot;&gt;Plotting the spectra :&lt;a aria-label=&quot;Anchor&quot; class=&quot;anchorjs-link&quot; data-anchorjs-icon=&quot;&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#plotting-the-spectra&quot; style=&quot;-webkit-font-smoothing: antialiased; background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #2761e3; font-family: anchorjs-icons; font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-size: 1em; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; font-weight: normal; line-height: 1; margin-left: 0.1875em; opacity: 0; padding-left: 0.1875em; padding-right: 0.1875em; text-decoration-line: none; text-underline-offset: 3px;&quot;&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Looking to the NIR spectra we can see that there are some artifacts in the spectra at 1000 nm and 1830 nm. These artifacts are due to the change of detector in the spectrometer. We can plot these artifacts using the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;ggplot2&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;package.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;In this case we are going to vave the plots and use the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;patchwork&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;package to combine them.&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb1&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb1-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;library&lt;/span&gt;(tidyverse)&lt;/span&gt;
&lt;span id=&quot;cb1-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;library&lt;/span&gt;(patchwork)&lt;/span&gt;
&lt;span id=&quot;cb1-3&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-3&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;load&lt;/span&gt;(&lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;C:/BLOG/Workspaces/NIR Soil Tutorial/post2.RData&quot;&lt;/span&gt;)&lt;/span&gt;
&lt;span id=&quot;cb1-4&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-4&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;/span&gt;
&lt;span id=&quot;cb1-5&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-5&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;artifact_1000nm &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ggplot&lt;/span&gt;(vnir_long,&lt;/span&gt;
&lt;span id=&quot;cb1-6&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-6&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;       &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;aes&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;x =&lt;/span&gt; wavelength, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;y =&lt;/span&gt; absorbance, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;group =&lt;/span&gt; sample)) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb1-7&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-7&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;geom_line&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;alpha =&lt;/span&gt; &lt;span class=&quot;fl&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;0.5&lt;/span&gt;) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb1-8&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-8&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;theme_minimal&lt;/span&gt;() &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb1-9&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-9&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;labs&lt;/span&gt;(&lt;/span&gt;
&lt;span id=&quot;cb1-10&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-10&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;    &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;title =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;Artifacts at 1000 nm&quot;&lt;/span&gt;,&lt;/span&gt;
&lt;span id=&quot;cb1-11&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-11&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;    &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;subtitle =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;Due to detector change&quot;&lt;/span&gt;,&lt;/span&gt;
&lt;span id=&quot;cb1-12&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-12&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;    &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;x =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;Wavelength (nm)&#39;&lt;/span&gt;,&lt;/span&gt;
&lt;span id=&quot;cb1-13&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-13&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;    &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;y =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;Calculated absorbance&#39;&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb1-14&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-14&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  ) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb1-15&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-15&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;coord_cartesian&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;xlim =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;c&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;990&lt;/span&gt;, &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1010&lt;/span&gt;), &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;ylim =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;c&lt;/span&gt;(&lt;span class=&quot;fl&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;0.4&lt;/span&gt;, &lt;span class=&quot;fl&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;0.45&lt;/span&gt;)) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb1-16&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-16&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;geom_vline&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;xintercept =&lt;/span&gt; &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1000&lt;/span&gt;, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;linetype =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;dashed&quot;&lt;/span&gt;, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;color =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;red&quot;&lt;/span&gt;)&lt;/span&gt;
&lt;span id=&quot;cb1-17&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-17&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;/span&gt;
&lt;span id=&quot;cb1-18&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-18&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;artifact_1830nm &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ggplot&lt;/span&gt;(vnir_long,&lt;/span&gt;
&lt;span id=&quot;cb1-19&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-19&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;       &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;aes&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;x =&lt;/span&gt; wavelength, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;y =&lt;/span&gt; absorbance, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;group =&lt;/span&gt; sample)) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb1-20&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-20&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;geom_line&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;alpha =&lt;/span&gt; &lt;span class=&quot;fl&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;0.5&lt;/span&gt;) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb1-21&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-21&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;theme_minimal&lt;/span&gt;() &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb1-22&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-22&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;labs&lt;/span&gt;(&lt;/span&gt;
&lt;span id=&quot;cb1-23&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-23&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;    &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;title =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;Artifacts at 1830 nm&quot;&lt;/span&gt;,&lt;/span&gt;
&lt;span id=&quot;cb1-24&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-24&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;    &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;subtitle =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;Less visible than at 1000 nm&quot;&lt;/span&gt;,&lt;/span&gt;
&lt;span id=&quot;cb1-25&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-25&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;    &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;x =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;Wavelength (nm)&#39;&lt;/span&gt;,&lt;/span&gt;
&lt;span id=&quot;cb1-26&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-26&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;    &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;y =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;Calculated absorbance&#39;&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb1-27&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-27&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  ) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb1-28&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-28&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;coord_cartesian&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;xlim =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;c&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1820&lt;/span&gt;, &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1840&lt;/span&gt;), &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;ylim =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;c&lt;/span&gt;(&lt;span class=&quot;fl&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;0.2&lt;/span&gt;, &lt;span class=&quot;fl&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;0.4&lt;/span&gt;)) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb1-29&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb1-29&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;geom_vline&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;xintercept =&lt;/span&gt; &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1830&lt;/span&gt;, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;linetype =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;dashed&quot;&lt;/span&gt;, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;color =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;red&quot;&lt;/span&gt;)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;level3&quot; id=&quot;combining-the-plots&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-size: 17px;&quot;&gt;&lt;h3 class=&quot;anchored&quot; data-anchor-id=&quot;combining-the-plots&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 1.45rem; line-height: 1.2; margin-bottom: 0.5rem; margin-top: 1.5rem; opacity: 0.9;&quot;&gt;Combining the plots&lt;a aria-label=&quot;Anchor&quot; class=&quot;anchorjs-link&quot; data-anchorjs-icon=&quot;&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#combining-the-plots&quot; style=&quot;-webkit-font-smoothing: antialiased; background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #2761e3; font-family: anchorjs-icons; font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-size: 1em; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; font-weight: normal; line-height: 1; margin-left: 0.1875em; opacity: 0; padding-left: 0.1875em; padding-right: 0.1875em; text-decoration-line: none; text-underline-offset: 3px;&quot;&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;We can combine both plots:&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb2&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb2-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#cb2-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;artifact_1000nm &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt; artifact_1830nm &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;plot_layout&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;ncol =&lt;/span&gt; &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;2&lt;/span&gt;)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;cell-output-display&quot; style=&quot;box-sizing: border-box; overflow-x: auto;&quot;&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;figure class=&quot;figure&quot; style=&quot;box-sizing: border-box; margin: 0px 0px 1rem;&quot;&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;img class=&quot;img-fluid figure-img&quot; src=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/index_files/figure-html/unnamed-chunk-2-1.png&quot; style=&quot;box-sizing: border-box; height: auto; line-height: 1; margin-bottom: 0.5rem; max-width: 100%; vertical-align: middle;&quot; width=&quot;672&quot; /&gt;&lt;/p&gt;&lt;/figure&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;level3&quot; id=&quot;bibliography&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&lt;h3 class=&quot;anchored&quot; data-anchor-id=&quot;bibliography&quot; style=&quot;box-sizing: border-box; font-size: 1.45rem; line-height: 1.2; margin-bottom: 0.5rem; margin-top: 1.5rem; opacity: 0.9;&quot;&gt;Bibliography:&lt;a aria-label=&quot;Anchor&quot; class=&quot;anchorjs-link&quot; data-anchorjs-icon=&quot;&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Looking%20for%20artifacts%20in%20the%20sample/#bibliography&quot; style=&quot;-webkit-font-smoothing: antialiased; background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #2761e3; font-family: anchorjs-icons; font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-size: 1em; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; font-weight: normal; line-height: 1; margin-left: 0.1875em; opacity: 0; padding-left: 0.1875em; padding-right: 0.1875em; text-decoration-line: none; text-underline-offset: 3px;&quot;&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;a href=&quot;https://openknowledge.fao.org/items/512257df-e01a-4340-9a75-a64c4dd54ac1&quot; style=&quot;--bs-link-color-rgb: 31, 78, 182; background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #1f4eb6; text-underline-offset: 3px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Soil spectroscopy training materia&lt;/em&gt;&lt;/span&gt;l&lt;/a&gt;&amp;nbsp;Wadoux, A., Ramirez-Lopez, L., Ge, Y., Barra, I. &amp;amp; Peng, Y. 2025. A course on applied data analytics for soil analysis with infrared spectroscopy – Soil spectroscopy training manual 2. Rome, FAO.&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;b&gt;Follow the posts on Netlify&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEglphkBoSG2NvsrUyzMPPYoh2BIyXmAfwIpbTunKW3HtAqEVn_3GP9TtEVwor2Rljm9pbsViprGtf8r5jKBczN4VZt3ZrWhAwz-5p-LiZcy7l3KxQdjfJS4Gf7QYHeoDyhkpqikuvojnkT0eXg-Jou3YyXJ2Zk0cjrGbjYkxCdZjHEZ0SqBQDnVKmPiIC-b&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;2000&quot; data-original-width=&quot;2000&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEglphkBoSG2NvsrUyzMPPYoh2BIyXmAfwIpbTunKW3HtAqEVn_3GP9TtEVwor2Rljm9pbsViprGtf8r5jKBczN4VZt3ZrWhAwz-5p-LiZcy7l3KxQdjfJS4Gf7QYHeoDyhkpqikuvojnkT0eXg-Jou3YyXJ2Zk0cjrGbjYkxCdZjHEZ0SqBQDnVKmPiIC-b&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;/section&gt;</content><link rel='replies' type='application/atom+xml' href='http://nir-quimiometria.blogspot.com/feeds/7757470945176521819/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/05/looking-for-artifacts-in-spectra.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/7757470945176521819'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/7757470945176521819'/><link rel='alternate' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/05/looking-for-artifacts-in-spectra.html' title='Looking for artifacts in the spectra'/><author><name>José Ramón Cuesta</name><uri>http://www.blogger.com/profile/01637083082643255576</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEglphkBoSG2NvsrUyzMPPYoh2BIyXmAfwIpbTunKW3HtAqEVn_3GP9TtEVwor2Rljm9pbsViprGtf8r5jKBczN4VZt3ZrWhAwz-5p-LiZcy7l3KxQdjfJS4Gf7QYHeoDyhkpqikuvojnkT0eXg-Jou3YyXJ2Zk0cjrGbjYkxCdZjHEZ0SqBQDnVKmPiIC-b=s72-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2424328492215531658.post-1994624846023920457</id><published>2025-05-31T20:18:00.003+02:00</published><updated>2025-05-31T20:47:04.619+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="NIR Soil Analysis"/><title type='text'>Plotting MIR spectra with ggplot2</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;section class=&quot;level3&quot; id=&quot;loading-and-preparing-the-mir-data.&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-size: 17px;&quot;&gt;&lt;h3 class=&quot;anchored&quot; data-anchor-id=&quot;loading-and-preparing-the-mir-data.&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 1.45rem; line-height: 1.2; margin-bottom: 0.5rem; margin-top: 0px; opacity: 0.9;&quot;&gt;Loading and preparing the MIR data.&lt;a aria-label=&quot;Anchor&quot; class=&quot;anchorjs-link&quot; data-anchorjs-icon=&quot;&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#loading-and-preparing-the-mir-data.&quot; style=&quot;-webkit-font-smoothing: antialiased; background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #2761e3; font-family: anchorjs-icons; font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-size: 1em; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; font-weight: normal; line-height: 1; margin-left: 0.1875em; opacity: 0; padding-left: 0.1875em; padding-right: 0.1875em; text-decoration-line: none; text-underline-offset: 3px;&quot;&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The data is available in the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;data&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;folder of the repository. Is in a CSV format and can be loaded using the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;read_csv&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;function from the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;readr&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;package.&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb1&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb1-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb1-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;library&lt;/span&gt;(readr)&lt;/span&gt;
&lt;span id=&quot;cb1-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb1-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;/span&gt;
&lt;span id=&quot;cb1-3&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb1-3&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;url_mir &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;https://raw.githubusercontent.com/FAO-SID/SoilFER-Spec/main/data/dat2MIR.csv&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb1-4&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb1-4&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;dat2MIR &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;read_csv&lt;/span&gt;(url_mir)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Now we will follow the instructions of the&amp;nbsp;&lt;a href=&quot;https://openknowledge.fao.org/items/512257df-e01a-4340-9a75-a64c4dd54ac1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #2761e3; text-underline-offset: 3px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Soil spectroscopy training materia&lt;/em&gt;&lt;/span&gt;l&lt;/a&gt;&amp;nbsp;changing the name of the first column (index of the samples) to&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;“sample”&lt;/em&gt;&lt;/span&gt;.&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb2&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb2-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb2-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;colnames&lt;/span&gt;(dat2MIR)[&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1&lt;/span&gt;] &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;sample&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb2-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb2-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;head&lt;/span&gt;(dat2MIR, &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;c&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;10&lt;/span&gt;, &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;7&lt;/span&gt;))&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;cell-output cell-output-stdout&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;pre style=&quot;background-color: initial; border: initial; box-sizing: border-box; color: black; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 1rem; margin-top: 0px; overflow: auto; padding: initial;&quot;&gt;&lt;code style=&quot;background-color: initial; box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; padding: 0.125rem 0.25rem; word-break: normal;&quot;&gt;# A tibble: 10 × 7
   sample `4001.65608` `3999.72758` `3997.79907` `3995.87056` `3993.94205`
    &amp;lt;dbl&amp;gt;        &amp;lt;dbl&amp;gt;        &amp;lt;dbl&amp;gt;        &amp;lt;dbl&amp;gt;        &amp;lt;dbl&amp;gt;        &amp;lt;dbl&amp;gt;
 1      1       0.180        0.18         0.180        0.180        0.181 
 2      2       0.150        0.151        0.151        0.151        0.151 
 3      3       0.0484       0.0487       0.0489       0.0491       0.0492
 4      4       0.133        0.133        0.133        0.134        0.134 
 5      5       0.227        0.228        0.228        0.228        0.228 
 6      6       0.120        0.120        0.121        0.121        0.121 
 7      7       0.312        0.313        0.313        0.313        0.314 
 8      8       0.225        0.226        0.226        0.226        0.227 
 9      9       0.218        0.219        0.220        0.220        0.221 
10     10       0.113        0.113        0.114        0.114        0.114 
# ℹ 1 more variable: `3992.01354` &amp;lt;dbl&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Looking to the CSV file, we see that the first column is the sample number, and the last one the organic carbon parameter. All the columns in the middle ate the wavenumbers.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Let´s create a vector with the wavenumbers. The wavenumbers are in the column names from the second to the penultimate column, so we can extract them using the following code:&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb4&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb4-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb4-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;wavenumbers &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;as.numeric&lt;/span&gt;(&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;colnames&lt;/span&gt;(dat2MIR)[&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;:&lt;/span&gt;(&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ncol&lt;/span&gt;(dat2MIR) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1&lt;/span&gt;)])&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Let´s prepare the wavenumbers vector to be used as column names in the matrix of spectra.&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb5&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb5-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb5-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;wavelengths_ir &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;round&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;10000000&lt;/span&gt; &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;/&lt;/span&gt; wavenumbers)&lt;/span&gt;
&lt;span id=&quot;cb5-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb5-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;wavenumbers_ir &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;round&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;10000000&lt;/span&gt;&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;/&lt;/span&gt;wavelengths_ir) &lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Convert to cm-1&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb6&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb6-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb6-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;my_spectra_ir &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;as.matrix&lt;/span&gt;(dat2MIR[, &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;:&lt;/span&gt;(&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ncol&lt;/span&gt;(dat2MIR) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1&lt;/span&gt;)])&lt;/span&gt;
&lt;span id=&quot;cb6-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb6-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;colnames&lt;/span&gt;(my_spectra_ir) &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; wavenumbers_ir&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Let´s prepare the MIR dataframe to work with it:&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb7&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb7-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb7-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;dat_mir &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; dat2MIR[, &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;c&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1767&lt;/span&gt;)]&lt;/span&gt;
&lt;span id=&quot;cb7-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb7-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;dat_mir&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc_raw_ir &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; my_spectra_ir&lt;/span&gt;
&lt;span id=&quot;cb7-3&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb7-3&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rm&lt;/span&gt;(my_spectra_ir)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb8&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb8-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb8-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;library&lt;/span&gt;(tidyverse)&lt;/span&gt;
&lt;span id=&quot;cb8-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb8-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;/span&gt;
&lt;span id=&quot;cb8-3&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb8-3&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;my_wavenumbers &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;as.numeric&lt;/span&gt;(&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;colnames&lt;/span&gt;(dat_mir&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc_raw_ir))&lt;/span&gt;
&lt;span id=&quot;cb8-4&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb8-4&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;/span&gt;
&lt;span id=&quot;cb8-5&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb8-5&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;#creating the long dataframe&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb8-6&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb8-6&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;ir_long &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;data.frame&lt;/span&gt;(&lt;/span&gt;
&lt;span id=&quot;cb8-7&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb8-7&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;sample =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rep&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;nrow&lt;/span&gt;(dat_mir), &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;each =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ncol&lt;/span&gt;(dat_mir&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc_raw_ir)),&lt;/span&gt;
&lt;span id=&quot;cb8-8&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb8-8&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;oc =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rep&lt;/span&gt;(dat_mir&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;Organic_Carbon, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;each =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ncol&lt;/span&gt;(dat_mir&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc_raw_ir)),&lt;/span&gt;
&lt;span id=&quot;cb8-9&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb8-9&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;wavenumber =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rep&lt;/span&gt;(my_wavenumbers, &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;nrow&lt;/span&gt;(dat_mir)),&lt;/span&gt;
&lt;span id=&quot;cb8-10&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb8-10&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;absorbance =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;as.vector&lt;/span&gt;(&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;t&lt;/span&gt;(dat_mir&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc_raw_ir))&lt;/span&gt;
&lt;span id=&quot;cb8-11&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb8-11&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;)&lt;/span&gt;
&lt;span id=&quot;cb8-12&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb8-12&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;/span&gt;
&lt;span id=&quot;cb8-13&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb8-13&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;head&lt;/span&gt;(ir_long)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;cell-output cell-output-stdout&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;pre style=&quot;background-color: initial; border: initial; box-sizing: border-box; color: black; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 1rem; margin-top: 0px; overflow: auto; padding: initial;&quot;&gt;&lt;code style=&quot;background-color: initial; box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; padding: 0.125rem 0.25rem; word-break: normal;&quot;&gt;  sample        oc wavenumber absorbance
1      1 0.7950426       4002    0.17972
2      1 0.7950426       4000    0.18000
3      1 0.7950426       3998    0.18025
4      1 0.7950426       3995    0.18048
5      1 0.7950426       3994    0.18076
6      1 0.7950426       3992    0.18107&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;We can use the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;ggplot&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;function to create a plot.&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb10&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb10-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb10-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ggplot&lt;/span&gt;(ir_long,&lt;/span&gt;
&lt;span id=&quot;cb10-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb10-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;       &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;aes&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;x =&lt;/span&gt; wavenumber, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;y =&lt;/span&gt; absorbance, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;group =&lt;/span&gt; sample, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;color =&lt;/span&gt; oc)) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb10-3&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb10-3&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;geom_line&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;alpha =&lt;/span&gt; &lt;span class=&quot;fl&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;0.5&lt;/span&gt;) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb10-4&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb10-4&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;scale_color_gradient&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;low =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;blue&#39;&lt;/span&gt;, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;high =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;red&#39;&lt;/span&gt;) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb10-5&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb10-5&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;scale_x_reverse&lt;/span&gt;() &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;  &lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Invierte el eje X&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb10-6&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb10-6&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;theme_minimal&lt;/span&gt;() &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb10-7&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb10-7&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;labs&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;x =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;Wavenumber (cm⁻¹)&#39;&lt;/span&gt;,&lt;/span&gt;
&lt;span id=&quot;cb10-8&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb10-8&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;       &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;y =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;Calculated absorbance&#39;&lt;/span&gt;,&lt;/span&gt;
&lt;span id=&quot;cb10-9&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#cb10-9&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;       &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;color =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;OC (%)&#39;&lt;/span&gt;)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;cell-output-display&quot; style=&quot;box-sizing: border-box; overflow-x: auto;&quot;&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;figure class=&quot;figure&quot; style=&quot;box-sizing: border-box; margin: 0px 0px 1rem;&quot;&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;img class=&quot;img-fluid figure-img&quot; src=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/index_files/figure-html/unnamed-chunk-8-1.png&quot; style=&quot;box-sizing: border-box; height: auto; line-height: 1; margin-bottom: 0.5rem; max-width: 100%; vertical-align: middle;&quot; width=&quot;672&quot; /&gt;&lt;/p&gt;&lt;/figure&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;level3&quot; id=&quot;bibliography&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-size: 17px;&quot;&gt;&lt;h3 class=&quot;anchored&quot; data-anchor-id=&quot;bibliography&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 1.45rem; line-height: 1.2; margin-bottom: 0.5rem; margin-top: 1.5rem; opacity: 0.9;&quot;&gt;Bibliography:&lt;a aria-label=&quot;Anchor&quot; class=&quot;anchorjs-link&quot; data-anchorjs-icon=&quot;&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Plotting%20the%20MIR%20spectra/#bibliography&quot; style=&quot;-webkit-font-smoothing: antialiased; background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #2761e3; font-family: anchorjs-icons; font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-size: 1em; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; font-weight: normal; line-height: 1; margin-left: 0.1875em; opacity: 0; padding-left: 0.1875em; padding-right: 0.1875em; text-decoration-line: none; text-underline-offset: 3px;&quot;&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;a href=&quot;https://openknowledge.fao.org/items/512257df-e01a-4340-9a75-a64c4dd54ac1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #2761e3; text-underline-offset: 3px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Soil spectroscopy training materia&lt;/em&gt;&lt;/span&gt;l&lt;/a&gt;&amp;nbsp;Wadoux, A., Ramirez-Lopez, L., Ge, Y., Barra, I. &amp;amp; Peng, Y. 2025. A course on applied data analytics for soil analysis with infrared spectroscopy – Soil spectroscopy training manual 2. Rome, FAO.&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Follow the NIR-Chemometrics blog on Netlify&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgJKDWsbG0CIbkiIK6IhVHL7P3OKwvH23SiQeDBpo8ueuCZeuaLQxFA0qlmfZmtcLXYrLF_BlO_KOzOxSx3fNWra19wu1svHSWs6_dzlL6xVeoH6SAgAcX4DVWpXEs2L6jYS0XiLkNf1gftmhiOHpDg3SZEh4B_epDkeHo8U9XKzMeqyxhTClLG5AVMS_ha&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;1600&quot; data-original-width=&quot;1600&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgJKDWsbG0CIbkiIK6IhVHL7P3OKwvH23SiQeDBpo8ueuCZeuaLQxFA0qlmfZmtcLXYrLF_BlO_KOzOxSx3fNWra19wu1svHSWs6_dzlL6xVeoH6SAgAcX4DVWpXEs2L6jYS0XiLkNf1gftmhiOHpDg3SZEh4B_epDkeHo8U9XKzMeqyxhTClLG5AVMS_ha&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;/section&gt;</content><link rel='replies' type='application/atom+xml' href='http://nir-quimiometria.blogspot.com/feeds/1994624846023920457/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/05/plotting-mir-spectra-with-ggplot2.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/1994624846023920457'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/1994624846023920457'/><link rel='alternate' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/05/plotting-mir-spectra-with-ggplot2.html' title='Plotting MIR spectra with ggplot2'/><author><name>José Ramón Cuesta</name><uri>http://www.blogger.com/profile/01637083082643255576</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEgJKDWsbG0CIbkiIK6IhVHL7P3OKwvH23SiQeDBpo8ueuCZeuaLQxFA0qlmfZmtcLXYrLF_BlO_KOzOxSx3fNWra19wu1svHSWs6_dzlL6xVeoH6SAgAcX4DVWpXEs2L6jYS0XiLkNf1gftmhiOHpDg3SZEh4B_epDkeHo8U9XKzMeqyxhTClLG5AVMS_ha=s72-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2424328492215531658.post-8109306467148789872</id><published>2025-05-31T20:04:00.001+02:00</published><updated>2025-05-31T20:04:19.846+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="NIR Soil Analysis"/><title type='text'>Plotting NIR spectra with ggplot2</title><content type='html'>&lt;div class=&quot;quarto-container page-columns page-rows-contents page-layout-article page-navbar&quot; id=&quot;quarto-content&quot; style=&quot;box-sizing: border-box; color: #343a40; display: grid; font-size: 17px; gap: 0px; grid-area: contents-top / screen-start / contents-bottom / screen-end; grid-template-columns: [screen-start] 1.5em [screen-start-inset] 5fr [page-start page-start-inset] 35px [body-start-outset] 35px [body-start] 1.5em [body-content-start] minmax(500px, calc(-3em + 850px)) [body-content-end] 1.5em [body-end] 35px [body-end-outset] 35px [page-end-inset page-end] 5fr [screen-end-inset] 1.5em; grid-template-rows: [content-top] minmax(max-content, 1fr) [content-bottom] minmax(60px, max-content) [page-bottom]; min-height: calc(-124px + 100vh); padding: 0px;&quot;&gt;&lt;main class=&quot;content quarto-banner-title-block&quot; id=&quot;quarto-document-content&quot; style=&quot;align-content: flex-start; box-sizing: border-box; grid-area: content-top / body-content-start / content-bottom / body-content-end; margin-bottom: 1em; margin-top: 1em; padding-top: 14px;&quot;&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This is the post number two of the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Soil spectroscopy training material&lt;/em&gt;&lt;/span&gt;. We are following the paper&amp;nbsp;&lt;a data-original-href=&quot;https://openknowledge.fao.org/items/512257df-e01a-4340-9a75-a64c4dd54ac1&quot; href=&quot;https://openknowledge.fao.org/items/512257df-e01a-4340-9a75-a64c4dd54ac1&quot; style=&quot;box-sizing: border-box; color: #2761e3; text-underline-offset: 3px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Soil spectroscopy training materia&lt;/em&gt;&lt;/span&gt;l&lt;/a&gt;&amp;nbsp;and at the same time we make small changes to the code.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;In the previous post, we plot the NIR spectra using the classical R function&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;matplot&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;. Now we want to use the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;ggplot2&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;package to plot the spectra but for that we have to prepare the data in a different way, creating a long format indeed a wide format.&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb1&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb1-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;library&lt;/span&gt;(tidyverse)&lt;/span&gt;
&lt;span id=&quot;cb1-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-2&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;load&lt;/span&gt;(&lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;dat.RData&quot;&lt;/span&gt;)&lt;/span&gt;
&lt;span id=&quot;cb1-3&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-3&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-3&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;load&lt;/span&gt;(&lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;C:/BLOG/Workspaces/NIR Soil Tutorial/post1.RData&quot;&lt;/span&gt;)&lt;/span&gt;
&lt;span id=&quot;cb1-4&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-4&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-4&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;#converting the wavelengths into numeric values&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb1-5&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-5&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-5&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;my_wavelengths &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;as.numeric&lt;/span&gt;(&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;colnames&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc_raw))&lt;/span&gt;
&lt;span id=&quot;cb1-6&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-6&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-6&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;/span&gt;
&lt;span id=&quot;cb1-7&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-7&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-7&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;#creating the long dataframe&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb1-8&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-8&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-8&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;vnir_long &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;data.frame&lt;/span&gt;(&lt;/span&gt;
&lt;span id=&quot;cb1-9&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-9&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-9&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;sample =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rep&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;nrow&lt;/span&gt;(dat), &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;each =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ncol&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc_raw)),&lt;/span&gt;
&lt;span id=&quot;cb1-10&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-10&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-10&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;oc =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rep&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;Organic_Carbon, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;each =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ncol&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc_raw)),&lt;/span&gt;
&lt;span id=&quot;cb1-11&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-11&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-11&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;clay =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rep&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;Clay, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;each =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ncol&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc_raw)),&lt;/span&gt;
&lt;span id=&quot;cb1-12&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-12&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-12&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;silt =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rep&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;Silt, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;each =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ncol&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc_raw)),&lt;/span&gt;
&lt;span id=&quot;cb1-13&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-13&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-13&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;sand =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rep&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;Sand, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;each =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ncol&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc_raw)),&lt;/span&gt;
&lt;span id=&quot;cb1-14&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-14&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-14&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;wavelength =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rep&lt;/span&gt;(my_wavelengths, &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;nrow&lt;/span&gt;(dat)),&lt;/span&gt;
&lt;span id=&quot;cb1-15&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-15&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-15&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;absorbance =&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;as.vector&lt;/span&gt;(&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;t&lt;/span&gt;(&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;log&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;/&lt;/span&gt; dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc_raw, &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;10&lt;/span&gt;))))&lt;/span&gt;
&lt;span id=&quot;cb1-16&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-16&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-16&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;/span&gt;
&lt;span id=&quot;cb1-17&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-17&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb1-17&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;head&lt;/span&gt;(vnir_long)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;cell-output cell-output-stdout&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;pre style=&quot;border: initial; box-sizing: border-box; color: black; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 1rem; margin-top: 0px; overflow: auto; padding: initial;&quot;&gt;&lt;code style=&quot;box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; padding: 0.125rem 0.25rem; word-break: normal;&quot;&gt;  sample        oc     clay silt sand wavelength absorbance
1      1 0.7950426 14.95713 40.1 44.9        350   1.206405
2      1 0.7950426 14.95713 40.1 44.9        351   1.204785
3      1 0.7950426 14.95713 40.1 44.9        352   1.225360
4      1 0.7950426 14.95713 40.1 44.9        353   1.239876
5      1 0.7950426 14.95713 40.1 44.9        354   1.238837
6      1 0.7950426 14.95713 40.1 44.9        355   1.235567&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;We can use the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;ggplot&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;function to create a plot.&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb3&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb3-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb3-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb3-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;ggplot&lt;/span&gt;(vnir_long,&lt;/span&gt;
&lt;span id=&quot;cb3-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb3-2&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb3-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;aes&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;x =&lt;/span&gt; wavelength, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;y =&lt;/span&gt; absorbance, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;group =&lt;/span&gt; sample, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;color =&lt;/span&gt; clay)) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb3-3&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb3-3&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb3-3&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;geom_line&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;alpha =&lt;/span&gt; &lt;span class=&quot;fl&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;0.5&lt;/span&gt;) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;co&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;# Set alpha to 0.5 for transparency&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb3-4&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb3-4&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb3-4&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;scale_color_gradient&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;low =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;blue&#39;&lt;/span&gt;, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;high =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;red&#39;&lt;/span&gt;) &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb3-5&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb3-5&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb3-5&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;theme_minimal&lt;/span&gt;() &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb3-6&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb3-6&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#cb3-6&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;  &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;labs&lt;/span&gt;(&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;x =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;Wavelength (nm)&#39;&lt;/span&gt;,&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;y =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;Calculated absorbance&#39;&lt;/span&gt;,&lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;color =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&#39;Clay (%)&#39;&lt;/span&gt;)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;cell-output-display&quot; style=&quot;box-sizing: border-box; overflow-x: auto;&quot;&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;figure class=&quot;figure&quot; style=&quot;box-sizing: border-box; margin: 0px 0px 1rem;&quot;&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;img class=&quot;img-fluid figure-img&quot; src=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/index_files/figure-html/unnamed-chunk-2-1.png&quot; style=&quot;box-sizing: border-box; height: auto; line-height: 1; margin-bottom: 0.5rem; max-width: 100%; vertical-align: middle;&quot; width=&quot;672&quot; /&gt;&lt;/p&gt;&lt;/figure&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This plot shows the spectra of the samples with the clay content as a color gradient (the paper use the organic carbon). The x-axis represents the wavelength in nano-meters, and the y-axis represents the calculated absorbance. The color gradient indicates the clay content, with blue representing the samples with the lower clay content and the red ones with the higher clay content.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Due to the scatter we don´t see any patters clearly in the spectra yet.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The paper also show us how to work with the MIR (Middle Infrared Spectra), so in the next post we will do the same as we did in these first two posts, but with the MIR dataframe.&lt;/span&gt;&lt;/p&gt;&lt;section class=&quot;level3&quot; id=&quot;bibliography&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;h3 class=&quot;anchored&quot; data-anchor-id=&quot;bibliography&quot; style=&quot;box-sizing: border-box; font-size: 1.45rem; line-height: 1.2; margin-bottom: 0.5rem; margin-top: 1.5rem; opacity: 0.9;&quot;&gt;Bibliography:&lt;a aria-label=&quot;Anchor&quot; class=&quot;anchorjs-link &quot; data-anchorjs-icon=&quot;&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/Let%C2%B4s%20plot%20the%20NIR%20Spectra%20with%20ggplot/#bibliography&quot; style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; color: #2761e3; font-family: anchorjs-icons; font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-size: 1em; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; font-weight: normal; line-height: 1; margin-left: 0.1875em; opacity: 0; padding-left: 0.1875em; padding-right: 0.1875em; text-decoration-line: none; text-underline-offset: 3px;&quot;&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;&lt;a data-original-href=&quot;https://openknowledge.fao.org/items/512257df-e01a-4340-9a75-a64c4dd54ac1&quot; href=&quot;https://openknowledge.fao.org/items/512257df-e01a-4340-9a75-a64c4dd54ac1&quot; style=&quot;box-sizing: border-box; color: #2761e3; text-underline-offset: 3px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Soil spectroscopy training materia&lt;/em&gt;&lt;/span&gt;l&lt;/a&gt;&amp;nbsp;Wadoux, A., Ramirez-Lopez, L., Ge, Y., Barra, I. &amp;amp; Peng, Y. 2025. A course on applied data analytics for soil analysis with infrared spectroscopy – Soil spectroscopy training manual 2. Rome, FAO.&lt;/p&gt;&lt;/section&gt;&lt;/main&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://nir-quimiometria.blogspot.com/feeds/8109306467148789872/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/05/plotting-nir-spectra-with-ggplot2.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/8109306467148789872'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/8109306467148789872'/><link rel='alternate' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/05/plotting-nir-spectra-with-ggplot2.html' title='Plotting NIR spectra with ggplot2'/><author><name>José Ramón Cuesta</name><uri>http://www.blogger.com/profile/01637083082643255576</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2424328492215531658.post-2780363672607643232</id><published>2025-04-25T20:42:00.001+02:00</published><updated>2025-05-31T20:13:13.813+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="NIR Soil Analysis"/><title type='text'>New &quot;Soil Near Infrared&quot;  Training Material  (part 1)</title><content type='html'>&lt;section class=&quot;level3&quot; id=&quot;load-and-prepare-the-data.&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-size: 17px;&quot;&gt;&lt;h3 class=&quot;anchored&quot; data-anchor-id=&quot;load-and-prepare-the-data.&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 1.45rem; line-height: 1.2; margin-bottom: 0.5rem; margin-top: 0px; opacity: 0.9;&quot;&gt;Load and prepare the data.&lt;a aria-label=&quot;Anchor&quot; class=&quot;anchorjs-link &quot; data-anchorjs-icon=&quot;&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#load-and-prepare-the-data.&quot; style=&quot;-webkit-font-smoothing: antialiased; background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #2761e3; font-family: anchorjs-icons; font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-size: 1em; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; font-weight: normal; line-height: 1; margin-left: 0.1875em; opacity: 0; padding-left: 0.1875em; padding-right: 0.1875em; text-decoration-line: none; text-underline-offset: 3px;&quot;&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The data is available in the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;data&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;folder of the repository. Is in a CSV format and can be loaded using the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;read_csv&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;function from the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;readr&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;package.&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb1&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb1-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb1-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb1-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;library&lt;/span&gt;(readr)&lt;/span&gt;
&lt;span id=&quot;cb1-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb1-2&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb1-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;/span&gt;
&lt;span id=&quot;cb1-3&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb1-3&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb1-3&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;url &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;https://raw.githubusercontent.com/FAO-SID/SoilFER-Spec/main/data/dat2.csv&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb1-4&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb1-4&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb1-4&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;dat2 &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;read_csv&lt;/span&gt;(url)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Now we will follow the instructions of the&amp;nbsp;&lt;a data-original-href=&quot;https://openknowledge.fao.org/items/512257df-e01a-4340-9a75-a64c4dd54ac1&quot; href=&quot;https://openknowledge.fao.org/items/512257df-e01a-4340-9a75-a64c4dd54ac1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #2761e3; text-underline-offset: 3px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Soil spectroscopy training materia&lt;/em&gt;&lt;/span&gt;l&lt;/a&gt;&amp;nbsp;changing the name of the first column (index of the samples) to&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;“sample”&lt;/em&gt;&lt;/span&gt;.&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb2&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb2-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb2-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb2-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;colnames&lt;/span&gt;(dat2)[&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1&lt;/span&gt;] &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;sample&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb2-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb2-2&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb2-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;head&lt;/span&gt;(dat2, &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;c&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;10&lt;/span&gt;, &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;7&lt;/span&gt;))&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;cell-output cell-output-stdout&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;pre style=&quot;background-color: initial; border: initial; box-sizing: border-box; color: black; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 1rem; margin-top: 0px; overflow: auto; padding: initial;&quot;&gt;&lt;code style=&quot;background-color: initial; box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; padding: 0.125rem 0.25rem; word-break: normal;&quot;&gt;# A tibble: 10 × 7
   sample Organic_Carbon  Clay  Silt  Sand   X350   X351
    &amp;lt;dbl&amp;gt;          &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;
 1      1          0.795 15.0   40.1  44.9 0.0622 0.0624
 2      2          0.696  8.79  52.5  38.7 0.0735 0.0725
 3      3          1.46  13.8   41.8  44.4 0.0685 0.0699
 4      4          3.36  31.1   49.5  19.4 0.0590 0.0615
 5      5          3.71  33.1   62.3   4.6 0.0624 0.0626
 6      6          1.39  33.3   60.6   6.1 0.0997 0.0988
 7      7          3.38  53.8   44.7   1.5 0.0920 0.0936
 8      8          3.16  27.3   66.3   6.4 0.0703 0.0673
 9      9          3.49  30.5   48.5  21   0.0473 0.0440
10     10          2.34  21.5   61.5  17   0.0666 0.0691&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Now we have the sample number, the four parameters and the wavelengths from 350 to 2500 nm in steps of 1 nm. In total we have 2151 wavelengths also called datapoints. Our next step is to remove the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;X&lt;/em&gt;&lt;/span&gt;&amp;nbsp;from the wavelengths column names. There are several ways to do this. One of the most common ways is to use the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;gsub&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;function which replaces all occurrences of a pattern in a string with a replacement string. In this case, we want to replace&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;“X”&lt;/span&gt;&amp;nbsp;with&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;““&lt;/em&gt;&lt;/span&gt;&amp;nbsp;(an empty string). We can do this for all the columns except the first four (sample number and parameters) using the following code:&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb4&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb4-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb4-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb4-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;colnames&lt;/span&gt;(dat2)[&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;c&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;5&lt;/span&gt;)] &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;gsub&lt;/span&gt;(&lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;X&quot;&lt;/span&gt;, &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;&quot;&lt;/span&gt;, &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;colnames&lt;/span&gt;(dat2)[&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;c&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;5&lt;/span&gt;)])&lt;/span&gt;
&lt;span id=&quot;cb4-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb4-2&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb4-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;head&lt;/span&gt;(dat2, &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;c&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;10&lt;/span&gt;, &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;7&lt;/span&gt;))&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;cell-output cell-output-stdout&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;pre style=&quot;background-color: initial; border: initial; box-sizing: border-box; color: black; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 1rem; margin-top: 0px; overflow: auto; padding: initial;&quot;&gt;&lt;code style=&quot;background-color: initial; box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; padding: 0.125rem 0.25rem; word-break: normal;&quot;&gt;# A tibble: 10 × 7
   sample Organic_Carbon  Clay  Silt  Sand  `350`  `351`
    &amp;lt;dbl&amp;gt;          &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;
 1      1          0.795 15.0   40.1  44.9 0.0622 0.0624
 2      2          0.696  8.79  52.5  38.7 0.0735 0.0725
 3      3          1.46  13.8   41.8  44.4 0.0685 0.0699
 4      4          3.36  31.1   49.5  19.4 0.0590 0.0615
 5      5          3.71  33.1   62.3   4.6 0.0624 0.0626
 6      6          1.39  33.3   60.6   6.1 0.0997 0.0988
 7      7          3.38  53.8   44.7   1.5 0.0920 0.0936
 8      8          3.16  27.3   66.3   6.4 0.0703 0.0673
 9      9          3.49  30.5   48.5  21   0.0473 0.0440
10     10          2.34  21.5   61.5  17   0.0666 0.0691&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Now we can isolate the wavelengths into a matrix. We can do this by using the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;as.matrix&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;function. The&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;as.matrix&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;function converts a data frame to a matrix. In this case, we want to convert all columns except the first four columns (sample number and parameters) to a matrix. We can do this using the following code:&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb6&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb6-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb6-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb6-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;my_spectra &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;as.matrix&lt;/span&gt;(dat2[, &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;c&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;5&lt;/span&gt;)])&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Now we remove the index and parameter columns from&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;dat2&lt;/em&gt;&lt;/span&gt;:&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb7&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb7-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb7-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb7-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;dat &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; dat2[, &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;c&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;5&lt;/span&gt;)]&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;and reassign the spectra to&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;dat&lt;/em&gt;&lt;/span&gt;&amp;nbsp;as a single variable called&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;spc_raw&lt;/em&gt;&lt;/span&gt;, and remove&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;my_spectra&lt;/em&gt;&lt;/span&gt;&amp;nbsp;from the environment.&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb8&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb8-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb8-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb8-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc_raw &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; my_spectra&lt;/span&gt;
&lt;span id=&quot;cb8-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb8-2&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb8-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rm&lt;/span&gt;(my_spectra)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;As a first check we can use matplot to visualize the spectra. We can use the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;matplot&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;function to plot the spectra. The&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;matplot&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;function is used to plot matrices. In this case, we want to plot the spectra (the matrix) against the wavelengths (the column names of the matrix). We can do this using the following code:&lt;/span&gt;&lt;/p&gt;&lt;/section&gt;&lt;section class=&quot;level3&quot; id=&quot;plot-the-spectra-using-classical-r&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-size: 17px;&quot;&gt;&lt;h3 class=&quot;anchored&quot; data-anchor-id=&quot;plot-the-spectra-using-classical-r&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 1.45rem; line-height: 1.2; margin-bottom: 0.5rem; margin-top: 1.5rem; opacity: 0.9;&quot;&gt;Plot the spectra (using classical R)&lt;a aria-label=&quot;Anchor&quot; class=&quot;anchorjs-link &quot; data-anchorjs-icon=&quot;&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#plot-the-spectra-using-classical-r&quot; style=&quot;-webkit-font-smoothing: antialiased; background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #2761e3; font-family: anchorjs-icons; font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-size: 1em; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; font-weight: normal; line-height: 1; margin-left: 0.1875em; opacity: 0; padding-left: 0.1875em; padding-right: 0.1875em; text-decoration-line: none; text-underline-offset: 3px;&quot;&gt;&lt;/a&gt;&lt;/h3&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb9&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb9-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb9-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb9-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;matplot&lt;/span&gt;(&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;colnames&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc_raw), &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;t&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc_raw), &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;type =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;l&quot;&lt;/span&gt;, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;lty =&lt;/span&gt; &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;col =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;grey&quot;&lt;/span&gt;, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;xlab =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;Wavelength (nm)&quot;&lt;/span&gt;, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;ylab =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;Reflectance (%)&quot;&lt;/span&gt;, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;main =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;NIR Spectra of the samples&quot;&lt;/span&gt;)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;cell-output-display&quot; style=&quot;box-sizing: border-box; overflow-x: auto;&quot;&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;figure class=&quot;figure&quot; style=&quot;box-sizing: border-box; margin: 0px 0px 1rem;&quot;&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;img class=&quot;img-fluid figure-img&quot; src=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/index_files/figure-html/unnamed-chunk-7-1.png&quot; style=&quot;box-sizing: border-box; height: auto; line-height: 1; margin-bottom: 0.5rem; max-width: 100%; vertical-align: middle;&quot; width=&quot;672&quot; /&gt;&lt;/p&gt;&lt;/figure&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This is my first approach to this training material. As you see in the paper the authors use this time the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;ggplot2&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;package to plot the spectra, and I will use it in the next post.&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb10&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb10-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb10-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb10-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;save.image&lt;/span&gt;(&lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;C:/BLOG/Workspaces/NIR Soil Tutorial/post1.RData&quot;&lt;/span&gt;)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;level3&quot; id=&quot;bibliography&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&lt;h3 class=&quot;anchored&quot; data-anchor-id=&quot;bibliography&quot; style=&quot;box-sizing: border-box; font-size: 1.45rem; line-height: 1.2; margin-bottom: 0.5rem; margin-top: 1.5rem; opacity: 0.9;&quot;&gt;Bibliography:&lt;a aria-label=&quot;Anchor&quot; class=&quot;anchorjs-link &quot; data-anchorjs-icon=&quot;&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#bibliography&quot; style=&quot;-webkit-font-smoothing: antialiased; background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #2761e3; font-family: anchorjs-icons; font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-size: 1em; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; font-weight: normal; line-height: 1; margin-left: 0.1875em; opacity: 0; padding-left: 0.1875em; padding-right: 0.1875em; text-decoration-line: none; text-underline-offset: 3px;&quot;&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;a data-original-href=&quot;https://openknowledge.fao.org/items/512257df-e01a-4340-9a75-a64c4dd54ac1&quot; href=&quot;https://openknowledge.fao.org/items/512257df-e01a-4340-9a75-a64c4dd54ac1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #2761e3; text-underline-offset: 3px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Soil spectroscopy training materia&lt;/em&gt;&lt;/span&gt;l&lt;/a&gt;&amp;nbsp;Wadoux, A., Ramirez-Lopez, L., Ge, Y., Barra, I. &amp;amp; Peng, Y. 2025. A course on applied data analytics for soil analysis with infrared spectroscopy – Soil spectroscopy training manual 2. Rome, FAO.&lt;/p&gt;&lt;/section&gt;</content><link rel='replies' type='application/atom+xml' href='http://nir-quimiometria.blogspot.com/feeds/2780363672607643232/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/04/new-soil-near-infrared-training.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/2780363672607643232'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/2780363672607643232'/><link rel='alternate' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/04/new-soil-near-infrared-training.html' title='New &quot;Soil Near Infrared&quot;  Training Material  (part 1)'/><author><name>José Ramón Cuesta</name><uri>http://www.blogger.com/profile/01637083082643255576</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2424328492215531658.post-90118747115575253</id><published>2025-04-13T00:00:00.001+02:00</published><updated>2025-05-31T20:09:04.224+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="NIR Soil Analysis"/><title type='text'>New Soil &quot;Near Infrared Spectroscopy&quot; Training Material</title><content type='html'>&lt;section class=&quot;level3&quot; id=&quot;load-and-prepare-the-data.&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-size: 17px;&quot;&gt;&lt;h3 class=&quot;anchored&quot; data-anchor-id=&quot;load-and-prepare-the-data.&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 1.45rem; line-height: 1.2; margin-bottom: 0.5rem; margin-top: 0px; opacity: 0.9;&quot;&gt;Load and prepare the data.&lt;a aria-label=&quot;Anchor&quot; class=&quot;anchorjs-link &quot; data-anchorjs-icon=&quot;&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#load-and-prepare-the-data.&quot; style=&quot;-webkit-font-smoothing: antialiased; background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #2761e3; font-family: anchorjs-icons; font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-size: 1em; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; font-weight: normal; line-height: 1; margin-left: 0.1875em; opacity: 0; padding-left: 0.1875em; padding-right: 0.1875em; text-decoration-line: none; text-underline-offset: 3px;&quot;&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The data is available in the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;data&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;folder of the repository. Is in a CSV format and can be loaded using the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;read_csv&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;function from the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;readr&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;package.&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb1&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb1-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb1-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb1-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;library&lt;/span&gt;(readr)&lt;/span&gt;
&lt;span id=&quot;cb1-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb1-2&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb1-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;/span&gt;
&lt;span id=&quot;cb1-3&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb1-3&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb1-3&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;url &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;https://raw.githubusercontent.com/FAO-SID/SoilFER-Spec/main/data/dat2.csv&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb1-4&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb1-4&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb1-4&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;dat2 &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;read_csv&lt;/span&gt;(url)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Now we will follow the instructions of the&amp;nbsp;&lt;a data-original-href=&quot;https://openknowledge.fao.org/items/512257df-e01a-4340-9a75-a64c4dd54ac1&quot; href=&quot;https://openknowledge.fao.org/items/512257df-e01a-4340-9a75-a64c4dd54ac1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #2761e3; text-underline-offset: 3px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Soil spectroscopy training materia&lt;/em&gt;&lt;/span&gt;l&lt;/a&gt;&amp;nbsp;changing the name of the first column (index of the samples) to&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;“sample”&lt;/em&gt;&lt;/span&gt;.&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb2&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb2-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb2-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb2-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;colnames&lt;/span&gt;(dat2)[&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1&lt;/span&gt;] &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;sample&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span id=&quot;cb2-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb2-2&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb2-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;head&lt;/span&gt;(dat2, &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;c&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;10&lt;/span&gt;, &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;7&lt;/span&gt;))&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;cell-output cell-output-stdout&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;pre style=&quot;background-color: initial; border: initial; box-sizing: border-box; color: black; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 1rem; margin-top: 0px; overflow: auto; padding: initial;&quot;&gt;&lt;code style=&quot;background-color: initial; box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; padding: 0.125rem 0.25rem; word-break: normal;&quot;&gt;# A tibble: 10 × 7
   sample Organic_Carbon  Clay  Silt  Sand   X350   X351
    &amp;lt;dbl&amp;gt;          &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;
 1      1          0.795 15.0   40.1  44.9 0.0622 0.0624
 2      2          0.696  8.79  52.5  38.7 0.0735 0.0725
 3      3          1.46  13.8   41.8  44.4 0.0685 0.0699
 4      4          3.36  31.1   49.5  19.4 0.0590 0.0615
 5      5          3.71  33.1   62.3   4.6 0.0624 0.0626
 6      6          1.39  33.3   60.6   6.1 0.0997 0.0988
 7      7          3.38  53.8   44.7   1.5 0.0920 0.0936
 8      8          3.16  27.3   66.3   6.4 0.0703 0.0673
 9      9          3.49  30.5   48.5  21   0.0473 0.0440
10     10          2.34  21.5   61.5  17   0.0666 0.0691&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Now we have the sample number, the four parameters and the wavelengths from 350 to 2500 nm in steps of 1 nm. In total we have 2151 wavelengths also called datapoints. Our next step is to remove the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;X&lt;/em&gt;&lt;/span&gt;&amp;nbsp;from the wavelengths column names. There are several ways to do this. One of the most common ways is to use the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;gsub&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;function which replaces all occurrences of a pattern in a string with a replacement string. In this case, we want to replace&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;“X”&lt;/span&gt;&amp;nbsp;with&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;““&lt;/em&gt;&lt;/span&gt;&amp;nbsp;(an empty string). We can do this for all the columns except the first four (sample number and parameters) using the following code:&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb4&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb4-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb4-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb4-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;colnames&lt;/span&gt;(dat2)[&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;c&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;5&lt;/span&gt;)] &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;gsub&lt;/span&gt;(&lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;X&quot;&lt;/span&gt;, &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;&quot;&lt;/span&gt;, &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;colnames&lt;/span&gt;(dat2)[&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;c&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;5&lt;/span&gt;)])&lt;/span&gt;
&lt;span id=&quot;cb4-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb4-2&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb4-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;head&lt;/span&gt;(dat2, &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;c&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;10&lt;/span&gt;, &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;7&lt;/span&gt;))&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;cell-output cell-output-stdout&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;pre style=&quot;background-color: initial; border: initial; box-sizing: border-box; color: black; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 1rem; margin-top: 0px; overflow: auto; padding: initial;&quot;&gt;&lt;code style=&quot;background-color: initial; box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; padding: 0.125rem 0.25rem; word-break: normal;&quot;&gt;# A tibble: 10 × 7
   sample Organic_Carbon  Clay  Silt  Sand  `350`  `351`
    &amp;lt;dbl&amp;gt;          &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt; &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;  &amp;lt;dbl&amp;gt;
 1      1          0.795 15.0   40.1  44.9 0.0622 0.0624
 2      2          0.696  8.79  52.5  38.7 0.0735 0.0725
 3      3          1.46  13.8   41.8  44.4 0.0685 0.0699
 4      4          3.36  31.1   49.5  19.4 0.0590 0.0615
 5      5          3.71  33.1   62.3   4.6 0.0624 0.0626
 6      6          1.39  33.3   60.6   6.1 0.0997 0.0988
 7      7          3.38  53.8   44.7   1.5 0.0920 0.0936
 8      8          3.16  27.3   66.3   6.4 0.0703 0.0673
 9      9          3.49  30.5   48.5  21   0.0473 0.0440
10     10          2.34  21.5   61.5  17   0.0666 0.0691&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Now we can isolate the wavelengths into a matrix. We can do this by using the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;as.matrix&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;function. The&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;as.matrix&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;function converts a data frame to a matrix. In this case, we want to convert all columns except the first four columns (sample number and parameters) to a matrix. We can do this using the following code:&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb6&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb6-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb6-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb6-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;my_spectra &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;as.matrix&lt;/span&gt;(dat2[, &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;c&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;5&lt;/span&gt;)])&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Now we remove the index and parameter columns from&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;dat2&lt;/em&gt;&lt;/span&gt;:&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb7&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb7-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb7-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb7-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;dat &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; dat2[, &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;c&lt;/span&gt;(&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;5&lt;/span&gt;)]&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;and reassign the spectra to&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;dat&lt;/em&gt;&lt;/span&gt;&amp;nbsp;as a single variable called&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;spc_raw&lt;/em&gt;&lt;/span&gt;, and remove&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;my_spectra&lt;/em&gt;&lt;/span&gt;&amp;nbsp;from the environment.&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb8&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb8-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb8-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb8-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc_raw &lt;span class=&quot;ot&quot; style=&quot;box-sizing: border-box; font-style: inherit;&quot;&gt;&amp;lt;-&lt;/span&gt; my_spectra&lt;/span&gt;
&lt;span id=&quot;cb8-2&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb8-2&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb8-2&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;rm&lt;/span&gt;(my_spectra)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;As a first check we can use matplot to visualize the spectra. We can use the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;matplot&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;function to plot the spectra. The&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;matplot&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;function is used to plot matrices. In this case, we want to plot the spectra (the matrix) against the wavelengths (the column names of the matrix). We can do this using the following code:&lt;/span&gt;&lt;/p&gt;&lt;/section&gt;&lt;section class=&quot;level3&quot; id=&quot;plot-the-spectra-using-classical-r&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-size: 17px;&quot;&gt;&lt;h3 class=&quot;anchored&quot; data-anchor-id=&quot;plot-the-spectra-using-classical-r&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 1.45rem; line-height: 1.2; margin-bottom: 0.5rem; margin-top: 1.5rem; opacity: 0.9;&quot;&gt;Plot the spectra (using classical R)&lt;a aria-label=&quot;Anchor&quot; class=&quot;anchorjs-link &quot; data-anchorjs-icon=&quot;&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#plot-the-spectra-using-classical-r&quot; style=&quot;-webkit-font-smoothing: antialiased; background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #2761e3; font-family: anchorjs-icons; font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-size: 1em; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; font-weight: normal; line-height: 1; margin-left: 0.1875em; opacity: 0; padding-left: 0.1875em; padding-right: 0.1875em; text-decoration-line: none; text-underline-offset: 3px;&quot;&gt;&lt;/a&gt;&lt;/h3&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb9&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb9-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb9-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb9-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;matplot&lt;/span&gt;(&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;colnames&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc_raw), &lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;t&lt;/span&gt;(dat&lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: #5e5e5e; font-style: inherit;&quot;&gt;$&lt;/span&gt;spc_raw), &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;type =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;l&quot;&lt;/span&gt;, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;lty =&lt;/span&gt; &lt;span class=&quot;dv&quot; style=&quot;box-sizing: border-box; color: #ad0000; font-style: inherit;&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;col =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;grey&quot;&lt;/span&gt;, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;xlab =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;Wavelength (nm)&quot;&lt;/span&gt;, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;ylab =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;Reflectance (%)&quot;&lt;/span&gt;, &lt;span class=&quot;at&quot; style=&quot;box-sizing: border-box; color: #657422; font-style: inherit;&quot;&gt;main =&lt;/span&gt; &lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;NIR Spectra of the samples&quot;&lt;/span&gt;)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;cell-output-display&quot; style=&quot;box-sizing: border-box; overflow-x: auto;&quot;&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;figure class=&quot;figure&quot; style=&quot;box-sizing: border-box; margin: 0px 0px 1rem;&quot;&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;img class=&quot;img-fluid figure-img&quot; src=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/index_files/figure-html/unnamed-chunk-7-1.png&quot; style=&quot;box-sizing: border-box; height: auto; line-height: 1; margin-bottom: 0.5rem; max-width: 100%; vertical-align: middle;&quot; width=&quot;672&quot; /&gt;&lt;/p&gt;&lt;/figure&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px; text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This is my first approach to this training material. As you see in the paper the authors use this time the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #7d12ba; font-size: 0.875em; font-weight: 400; overflow-wrap: break-word; padding: 0.2em; white-space-collapse: preserve;&quot;&gt;ggplot2&lt;/code&gt;&lt;/em&gt;&lt;/span&gt;&amp;nbsp;package to plot the spectra, and I will use it in the next post.&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;cell&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;;&quot;&gt;&lt;div class=&quot;sourceCode cell-code&quot; id=&quot;cb10&quot; style=&quot;background-color: rgba(233, 236, 239, 0.65); border: 1px solid rgba(233, 236, 239, 0.65); box-sizing: border-box; color: #003b4f; margin: 1em 0px; overflow: auto hidden;&quot;&gt;&lt;pre class=&quot;sourceCode r code-with-copy&quot; style=&quot;background-color: rgba(0, 0, 0, 0); border: none; box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace; font-size: 0.875em; line-height: 1.5; margin-bottom: 0px; margin-top: 0px; overflow: visible !important; padding: 0.4em; position: relative;&quot;&gt;&lt;code class=&quot;sourceCode r&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: inherit; display: block; font-family: inherit; font-size: inherit; font-weight: inherit; overflow-wrap: break-word; overflow: visible; padding: 0.125rem 0.25rem; position: relative; word-break: normal;&quot;&gt;&lt;span id=&quot;cb10-1&quot; style=&quot;box-sizing: border-box; line-height: 1.25; text-decoration: inherit;&quot;&gt;&lt;a aria-hidden=&quot;true&quot; data-original-href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb10-1&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#cb10-1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; text-decoration-color: rgb(108, 117, 125); text-decoration-line: none; text-underline-offset: 3px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/a&gt;&lt;span class=&quot;fu&quot; style=&quot;box-sizing: border-box; color: #4758ab; font-style: inherit;&quot;&gt;save.image&lt;/span&gt;(&lt;span class=&quot;st&quot; style=&quot;box-sizing: border-box; color: #20794d; font-style: inherit;&quot;&gt;&quot;C:/BLOG/Workspaces/NIR Soil Tutorial/post1.RData&quot;&lt;/span&gt;)&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;code-copy-button&quot; style=&quot;appearance: button; border-color: initial; border-radius: 0px; border-style: initial; border-width: 0px; cursor: pointer; font-family: inherit; font-size: inherit; line-height: inherit; margin: 5px 5px 0px 0px; position: absolute; right: 0px; top: 0px; z-index: 3;&quot; title=&quot;Copy to Clipboard&quot;&gt;&lt;i class=&quot;bi&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;/i&gt;&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;section class=&quot;level3&quot; id=&quot;bibliography&quot; style=&quot;background-color: white; box-sizing: border-box; color: #343a40; font-family: &amp;quot;Source Sans Pro&amp;quot;, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 17px;&quot;&gt;&lt;h3 class=&quot;anchored&quot; data-anchor-id=&quot;bibliography&quot; style=&quot;box-sizing: border-box; font-size: 1.45rem; line-height: 1.2; margin-bottom: 0.5rem; margin-top: 1.5rem; opacity: 0.9;&quot;&gt;Bibliography:&lt;a aria-label=&quot;Anchor&quot; class=&quot;anchorjs-link &quot; data-anchorjs-icon=&quot;&quot; href=&quot;https://nir-chemometrics.netlify.app/posts/New%20Soil%20Near%20Infrared%20Training%20Material/#bibliography&quot; style=&quot;-webkit-font-smoothing: antialiased; background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #2761e3; font-family: anchorjs-icons; font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-size: 1em; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; font-weight: normal; line-height: 1; margin-left: 0.1875em; opacity: 0; padding-left: 0.1875em; padding-right: 0.1875em; text-decoration-line: none; text-underline-offset: 3px;&quot;&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p style=&quot;box-sizing: border-box; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;a data-original-href=&quot;https://openknowledge.fao.org/items/512257df-e01a-4340-9a75-a64c4dd54ac1&quot; href=&quot;https://openknowledge.fao.org/items/512257df-e01a-4340-9a75-a64c4dd54ac1&quot; style=&quot;background-color: rgba(0, 0, 0, 0); box-sizing: border-box; color: #2761e3; text-underline-offset: 3px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Soil spectroscopy training materia&lt;/em&gt;&lt;/span&gt;l&lt;/a&gt;&amp;nbsp;Wadoux, A., Ramirez-Lopez, L., Ge, Y., Barra, I. &amp;amp; Peng, Y. 2025. A course on applied data analytics for soil analysis with infrared spectroscopy – Soil spectroscopy training manual 2. Rome, FAO.&lt;/p&gt;&lt;/section&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;mso-ansi-language: EN-GB;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://nir-quimiometria.blogspot.com/feeds/90118747115575253/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/04/new-soil-near-infrared-spectroscopy.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/90118747115575253'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/90118747115575253'/><link rel='alternate' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/04/new-soil-near-infrared-spectroscopy.html' title='New Soil &quot;Near Infrared Spectroscopy&quot; Training Material'/><author><name>José Ramón Cuesta</name><uri>http://www.blogger.com/profile/01637083082643255576</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2424328492215531658.post-8655240320312663271</id><published>2025-03-19T12:05:00.002+01:00</published><updated>2025-03-19T12:05:37.580+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Puerto de Avilés"/><title type='text'>Estadísticas de tráfico marítimo en el puerto de Avilés (parte 2)</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;span style=&quot;font-family: verdana;&quot;&gt;Una de las preguntas que nos podemos hacer con los datos que proporciona la web del puerto de Avilés, es:&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;b&gt;¿Que mercancías se exportaron principalmente del Puerto de Avilés en 2024?&lt;/b&gt;.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&amp;nbsp;La respuesta es clara:&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNK3OwoXGQtxidorPxp3chq_aHKcN1dJdLyYtFOfYfMpkYTPbxGxGNEqXil59qZgBNO6V3NYV0XX-WgIZVFKqby4FRkf38EEPhHxmSLKPqYx2OI6w_dugD2Somup-rv7qKSpsnfrFkhMc6dHAep_HVLvA7ToFDZisGaHXs7LJ6ywXHws_xYBHoN6pV0-Im/s917/Mercancias%20embarcadas%202024.jpeg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;683&quot; data-original-width=&quot;917&quot; height=&quot;475&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNK3OwoXGQtxidorPxp3chq_aHKcN1dJdLyYtFOfYfMpkYTPbxGxGNEqXil59qZgBNO6V3NYV0XX-WgIZVFKqby4FRkf38EEPhHxmSLKPqYx2OI6w_dugD2Somup-rv7qKSpsnfrFkhMc6dHAep_HVLvA7ToFDZisGaHXs7LJ6ywXHws_xYBHoN6pV0-Im/w640-h475/Mercancias%20embarcadas%202024.jpeg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;i&gt;No es sorprendente, ya que en Avilés se encuentra una fábrica de &lt;a href=&quot;https://spain.arcelormittal.com/que-hacemos/productos-planos/aviles/&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;ArcelorMittal&lt;/b&gt;&lt;/a&gt;.&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;podemos seguir haciéndonos preguntas:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;b&gt;Cual es el destino de los buques con estas boninas embarcadas?&lt;/b&gt;.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5YLnDZbkOdf5foTspM9lV_Ylpg9Fr5Yd-Zb4z5eLGGWWro8suQeF0O22oRk3LKbo5Pidy3NXruZzwf3ifhhEnzUgRaAXZoTW5pOgGJ3zkvlwk3lgt6b6w_Wze2hcsUNU6GQ0QOhOkXU3iAQNdzvNcraOdl01wP4Q7dQ28Sck2qyZoyCpZx68vg-TybyzY/s715/embarques%20bobinas%20de%20Acero%202024.jpeg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;647&quot; data-original-width=&quot;715&quot; height=&quot;580&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5YLnDZbkOdf5foTspM9lV_Ylpg9Fr5Yd-Zb4z5eLGGWWro8suQeF0O22oRk3LKbo5Pidy3NXruZzwf3ifhhEnzUgRaAXZoTW5pOgGJ3zkvlwk3lgt6b6w_Wze2hcsUNU6GQ0QOhOkXU3iAQNdzvNcraOdl01wP4Q7dQ28Sck2qyZoyCpZx68vg-TybyzY/w640-h580/embarques%20bobinas%20de%20Acero%202024.jpeg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&amp;nbsp;Vemos que el principal destino de las bobinas es Ravenna (Italia).&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;b&gt;¿Qué tonelaje tenía cada envío a lo largo del 2024?&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxN8Wzot9qLgq3cfXIN2TYFNcUEejvp00qVUL9Q_YAdSFpRWXtrXqtDkCL3MhYlz78g_i4DogFREUzpWzL-_00N3JuGAt3hK_X0isX-ZQdwQNQYOvY88uOuEcO6q4KcEaf5FuAT_C4KZRGIj97DZpzyTLcEDPyt7QkHLFFEUQ67Z16GgZiVEcFazDb6CmI/s1377/Tonelaje%20embarcado%20bobinas%20acero%202024.jpeg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;683&quot; data-original-width=&quot;1377&quot; height=&quot;318&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxN8Wzot9qLgq3cfXIN2TYFNcUEejvp00qVUL9Q_YAdSFpRWXtrXqtDkCL3MhYlz78g_i4DogFREUzpWzL-_00N3JuGAt3hK_X0isX-ZQdwQNQYOvY88uOuEcO6q4KcEaf5FuAT_C4KZRGIj97DZpzyTLcEDPyt7QkHLFFEUQ67Z16GgZiVEcFazDb6CmI/w640-h318/Tonelaje%20embarcado%20bobinas%20acero%202024.jpeg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;Podemos comprobar como las herramientas de los paquetes de R (ggplot2,...) nos permiten realizar gráficos muy claros para interpretar datos de hojas Excel o bases de datos que dispongamos.&lt;/span&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://nir-quimiometria.blogspot.com/feeds/8655240320312663271/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/03/estadisticas-de-trafico-maritimo-en-el_19.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/8655240320312663271'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/8655240320312663271'/><link rel='alternate' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/03/estadisticas-de-trafico-maritimo-en-el_19.html' title='Estadísticas de tráfico marítimo en el puerto de Avilés (parte 2)'/><author><name>José Ramón Cuesta</name><uri>http://www.blogger.com/profile/01637083082643255576</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNK3OwoXGQtxidorPxp3chq_aHKcN1dJdLyYtFOfYfMpkYTPbxGxGNEqXil59qZgBNO6V3NYV0XX-WgIZVFKqby4FRkf38EEPhHxmSLKPqYx2OI6w_dugD2Somup-rv7qKSpsnfrFkhMc6dHAep_HVLvA7ToFDZisGaHXs7LJ6ywXHws_xYBHoN6pV0-Im/s72-w640-h475-c/Mercancias%20embarcadas%202024.jpeg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2424328492215531658.post-2575443934608235195</id><published>2025-03-18T12:58:00.000+01:00</published><updated>2025-03-18T12:58:33.032+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Puerto de Avilés"/><title type='text'>Estadísticas de trafico marítimo en el puerto de Avilés (parte 1)</title><content type='html'>&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Con el fin de coger práctica con R y las herramientas de tidyverse, durante los próximos post trabajaré con los datos que aporta la página web del puerto de Avilés para analizar diferentes estadísticas sobre el uso del puerto para embarque y desembarque de mercancías en el año 2024. Para ello es interesante acceder a la página web de dicho puerto y descargar la hoja Excel con dichos datos e importar dicha hoja a R, aunque es preferible que arregléis previamente dicha Excel antes de la importación a RStudio.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Este es el enlace de la página web del puerto: &lt;a href=&quot;https://www.puertoaviles.es/es/puerto/comercial/muelles.asp&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;puerto de Avilés&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;En está página hay un enlace a &lt;a href=&quot;https://www.puertoaviles.es/es/servicioscomerciales/buquesenelpuerto.asp&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;&quot;Buques en el puerto&quot;&lt;/b&gt;&lt;/a&gt;&amp;nbsp;y desde ahí podéis seleccionar la opción &quot;Histórico de movimientos&quot; y descargaros la hoja excel que incluye los datos desde el 1 de enero de 2024 hasta la fecha que hagáis la descarga.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;He estado trabajando con la hoja Excel y pronto la tendré disponible si queréis ahorraros los pasos, aunque os los recomiendo para que vayáis cogiendo soltura con el manejo de Excel previo a la importación a RStudio.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Recientemente he estado haciendo unas visitas al puerto y es muy interesante el tema del tráfico marítimo, así como toda la industria que se genera entorno a los puertos.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Incluyo en este post una foto de un buque de más de 190 metros de eslora entrando al puerto.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJ5BsZ1j5gwIg3QHirjlTbXWQ5wjyJpX8DkfiBuV0F6kLWKjjV0A9vNME4celGYf_DPtnOoEuNo8p8fqvkLaLnTwtgPiJzlj_bDHrQ5zaFps4VNP_rNSR6JPDJ0OAkzRDt8aZ_ctG1o_s2ZSkJJHsxB7pzxg1A7Sd89xaZLGAYtIXJ2SBjmIcRykuScSnu/s4032/IMG_E2365%5B1%5D.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;2268&quot; data-original-width=&quot;4032&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJ5BsZ1j5gwIg3QHirjlTbXWQ5wjyJpX8DkfiBuV0F6kLWKjjV0A9vNME4celGYf_DPtnOoEuNo8p8fqvkLaLnTwtgPiJzlj_bDHrQ5zaFps4VNP_rNSR6JPDJ0OAkzRDt8aZ_ctG1o_s2ZSkJJHsxB7pzxg1A7Sd89xaZLGAYtIXJ2SBjmIcRykuScSnu/w640-h360/IMG_E2365%5B1%5D.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://nir-quimiometria.blogspot.com/feeds/2575443934608235195/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/03/estadisticas-de-trafico-maritimo-en-el.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/2575443934608235195'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2424328492215531658/posts/default/2575443934608235195'/><link rel='alternate' type='text/html' href='http://nir-quimiometria.blogspot.com/2025/03/estadisticas-de-trafico-maritimo-en-el.html' title='Estadísticas de trafico marítimo en el puerto de Avilés (parte 1)'/><author><name>José Ramón Cuesta</name><uri>http://www.blogger.com/profile/01637083082643255576</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJ5BsZ1j5gwIg3QHirjlTbXWQ5wjyJpX8DkfiBuV0F6kLWKjjV0A9vNME4celGYf_DPtnOoEuNo8p8fqvkLaLnTwtgPiJzlj_bDHrQ5zaFps4VNP_rNSR6JPDJ0OAkzRDt8aZ_ctG1o_s2ZSkJJHsxB7pzxg1A7Sd89xaZLGAYtIXJ2SBjmIcRykuScSnu/s72-w640-h360-c/IMG_E2365%5B1%5D.JPG" height="72" width="72"/><thr:total>0</thr:total></entry></feed>