
Reflectance/absorbance conversion constructor for spectral preprocessing
Source:R/prep_transform.R
prep_transform.RdCreates a preprocessing constructor for converting spectral data between
reflectance and absorbance. The constructor is intended to be passed to
preprocess_recipe and executed via process.
Usage
prep_transform(to = c("absorbance", "reflectance"))Value
An object of class preprocessing to be used in
preprocess_recipe and executed by process.
Details
Conversion follows Beer's Law:
\[A = -\log_{10}(R)\]
where \(A\) is absorbance and \(R\) is reflectance.
When converting to absorbance, all values in X must be strictly
positive. A warning is issued if the resulting absorbance contains small
negative values, which may indicate precision or scaling issues in the
input.
Note that no check is performed on whether the input is actually in the expected unit (the transformation is applied as specified).
Examples
data("NIRcannabis")
X <- NIRcannabis$spc # absorbance
tr <- prep_transform(to = "reflectance")
recipe <- preprocess_recipe(tr, device = "proxiscout")
X_ref <- process(X, recipe)