
Wavelength trimming constructor for spectral preprocessing
Source:R/prep_wav_trim.R
prep_wav_trim.RdCreates a preprocessing constructor for trimming spectral data to a
specified wavelength band. The constructor is intended to be passed to
preprocess_recipe and executed via process.
Arguments
- band
A numeric vector of length 2 giving the minimum and maximum wavenumber/wavelength to retain. Columns of
Xoutside this range are dropped. Passc()(empty vector) to skip band trimming and only applytrim_constant_edges.- trim_constant_edges
A logical. If
TRUE, constant or zero-valued columns at the left and right edges are removed after band trimming. Default isFALSE.
Value
An object of class preprocessing to be used in
preprocess_recipe and executed by process.
Details
Band trimming retains only those columns whose names (coerced to numeric)
fall within [min(band), max(band)]. If no columns fall within the
band the original matrix is returned with a warning.
Constant edge trimming scans inward from each edge and drops columns that are identical to their immediate neighbour or are all zero. If trimming would leave fewer than two columns the step is skipped with a warning.
Examples
data("NIRcannabis")
X <- NIRcannabis$spc
tr <- prep_wav_trim(band = c(1000, 1800))
recipe <- preprocess_recipe(tr, device = "proxiscout")
X_trim <- process(X, recipe)