prep_transform: Reflectance/absorbance conversion constructor for spectral...

View source: R/prep_transform.R

prep_transformR Documentation

Reflectance/absorbance conversion constructor for spectral preprocessing

Description

\loadmathjax

Creates 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"))

Arguments

to

A character string specifying the target unit. Either "absorbance" (default) or "reflectance".

Details

Conversion follows Beer's Law:

\mjdeqn

A = -\log_10(R)A = -log10(R)

where \mjeqnAA is absorbance and \mjeqnRR 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).

Value

An object of class preprocessing to be used in preprocess_recipe and executed by process.

Author(s)

Leonardo Ramirez-Lopez

See Also

preprocess_recipe, process

Examples

data("proximateCannabis")
X <- proximateCannabis$spc # absorbance

tr <- prep_transform(to = "reflectance")
recipe <- preprocess_recipe(tr, device = "proxiscout")
X_ref <- process(X, recipe)


proximetricsR documentation built on Sept. 4, 2026, 5:08 p.m.