prep_wav_trim: Wavelength trimming constructor for spectral preprocessing
Description
Creates 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.
An object of class preprocessing to be used in
preprocess_recipe and executed by process.
Arguments
band
A numeric vector of length 2 giving the minimum and maximum
wavenumber/wavelength to retain. Columns of X outside this range are dropped.
Pass c() (empty vector) to skip band trimming and only apply
trim_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
is FALSE.
Author
Claudio Orellano and Leonardo Ramirez-Lopez
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.