2 may 2021

Working with Soilspec data (part 4)

 Normally I use to work in the NIR instruments I use with spectra in Absorbance  units. As we saw in  "Working with Soilspec data (part 1)" the spectra data in the "datsoilspc" data set, the spectra is in Reflectance units, so if you prefer to work with Absorbance units, we have to calculate the "log 1/R" for every element in the reflectance X matrix, and we can do that with the "apply" function in R:

#First we writte the function

log1R<- function(x) {
                     return(log(1/x))
                     }

 #After we apply it to the X reflectance matrix

 spectra_abs = apply(spectra, 2, log1R)

This way we get the "log 1/R" spectra


 

No hay comentarios:

Publicar un comentario