View source: R/preprocess_recipe.R
| preprocess_recipe | R Documentation |
The preprocess_recipe function assembles an ordered sequence of
preprocessing steps into a recipe, while process executes the
recipe on a spectral data matrix.
preprocess_recipe(..., device)
process(X, recipe, device)
... |
one or more objects of class
The order in which the objects are provided defines the order of execution.
If no arguments are provided, an empty recipe is returned and |
device |
a character string specifying the target device:
|
X |
a numeric matrix of spectral data to be preprocessed (samples in rows, wavelengths in columns). |
recipe |
an object of class |
For preprocess_recipe, an object of class preprocess_recipe with
three components: steps (the ordered list of preprocessing step
objects), device (the target device string), and
preprocessing_order (a simplified string summarising the
sequence of applied transformations).
For process, a numeric matrix of preprocessed spectral data. The
applied recipe is stored as the attribute "preprocess_recipe" on the
returned matrix and can be retrieved with
attr(result, "preprocess_recipe").
Leonardo Ramirez-Lopez
prep_smooth, prep_snv,
prep_derivative, prep_resample,
prep_detrend, prep_transform,
prep_wav_trim
data("proximateCannabis")
X <- proximateCannabis$spc
# SNV alone — no device needed (SNV is device-agnostic)
recipe_snv <- preprocess_recipe(prep_snv())
X_snv <- process(X, recipe_snv)
# Any other combination requires device
recipe <- preprocess_recipe(
prep_smooth(w = 7, p = 1, algorithm = "savitzky-golay"),
prep_snv(),
prep_derivative(m = 1, w = 5, p = 2, algorithm = "savitzky-golay"),
device = "proxiscout"
)
X_proc <- process(X, recipe)
attr(X_proc, "preprocess_recipe")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.