
Pretreat spectral data according to user-designated method
Source:R/pretreat_spectra.R
pretreat_spectra.RdPretreatment, also known as preprocessing, is often used to
increase the signal to noise ratio in vis-NIR datasets. The waves
function pretreat_spectra applies common spectral pretreatment
methods such as standard normal variate and the Savitzky-Golay filter.
Usage
pretreat_spectra(
df,
test.data = NULL,
pretreatment = 1,
preprocessing.method = lifecycle::deprecated(),
wavelengths = lifecycle::deprecated()
)Arguments
- df
data.frameobject containing spectral data. First column(s) (optional) include metadata (with or without reference value column) followed by spectral columns. Spectral column names must be formatted as "X" followed by wavelength Include no other columns to right of spectra! No missing values permitted.- test.data
data.frameobject with same format as train.data. Will be appended todfduring pretreatment so that the same transformations are applied to each row. Default isNULL.- pretreatment
Number or list of numbers 1:13 corresponding to desired pretreatment method(s):
Raw data (default)
Standard normal variate (SNV)
SNV and first derivative
SNV and second derivative
First derivative
Second derivative
Savitzky–Golay filter (SG)
SNV and SG
Gap-segment derivative (window size = 11)
SG and first derivative (window size = 5)
SG and first derivative (window size = 11)
SG and second derivative (window size = 5)
SG and second derivative (window size = 11)
- preprocessing.method
DEPRECATED
preprocessing.methodhas been renamed "pretreatment"- wavelengths
DEPRECATED
wavelengthsis no longer supported; this information is now inferred fromdfcolumn names
Author
Jenna Hershberger jmh579@cornell.edu
Examples
pretreat_spectra(df = ikeogu.2017, pretreatment = 3)[1:5, 1:5]
#> study.name sample.id DMC.oven TCC X351
#> 1 C16Mcal C16Mcal_1 39.62109 1.002029 0.013447658
#> 2 C16Mcal C16Mcal_2 35.52017 17.034718 -0.008428511
#> 3 C16Mcal C16Mcal_3 42.04462 21.616243 0.055000011
#> 4 C16Mcal C16Mcal_4 39.00999 2.428640 -0.001007054
#> 5 C16Mcal C16Mcal_5 33.44273 24.012182 0.054048209