R/pretreat_spectra.R
pretreat_spectra.Rd
Pretreatment, 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.
pretreat_spectra(
df,
test.data = NULL,
pretreatment = 1,
preprocessing.method = deprecated(),
wavelengths = deprecated()
)
data.frame
object 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.
data.frame
object with same format as train.data.
Will be appended to df
during pretreatment so that the same
transformations are applied to each row. Default is NULL
.
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)
DEPRECATED preprocessing.method
has been renamed "pretreatment"
DEPRECATED wavelengths
is no
longer supported; this information is now inferred from df
column names
Pretreated df
` (or list of data.frame
s) with
reference column intact
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