View source: R/recipe_steps_preprocessing.R
| step_msc | R Documentation |
step_msc() creates a specification of a recipe step that corrects
each spectrum for multiplicative and additive effects relative to a
reference spectrum, with msc().
step_msc(
recipe,
...,
role = NA,
trained = FALSE,
robust = TRUE,
drop_offset = TRUE,
window = NULL,
reference = NULL,
columns = NULL,
skip = FALSE,
id = recipes::rand_id("msc"),
drop.offset = deprecated()
)
recipe |
A recipe object. The step will be added to the sequence of operations for this recipe. |
... |
One or more selector functions to choose the predictors (for
example, the spectral channels). See |
role |
Not used by this step, since no new variables are created. |
trained |
A logical indicating whether the step has been trained. |
robust |
A logical: use the median ( |
drop_offset |
A logical: remove the additive offset ( |
window |
An optional list of column index vectors (within the
selected columns) for piecewise MSC. See |
reference |
The reference spectrum, stored once the step has been trained. |
columns |
The names of the selected columns, stored once the step has been trained. |
skip |
A logical. Should the step be skipped when the recipe is baked
by |
id |
A character string that is unique to this step. |
drop.offset |
The reference spectrum (the median or mean of the training spectra) is
estimated when the recipe is prepped, and new spectra are corrected
against it when they are baked. The selected columns form one spectrum per
row. They are replaced by the corrected values. tidy()
returns the selected terms, the reference value of each (NA before
the step is trained) and id.
An updated version of recipe with the new step added to the
sequence of existing steps.
msc(), step_emsc()
data(forageLIBS)
# potassium and the K I resonance lines
wl <- suppressWarnings(as.numeric(names(forageLIBS)))
dat <- forageLIBS[c(which(names(forageLIBS) == "K"), which(wl > 760 & wl < 780))]
rec <- recipes::recipe(K ~ ., data = dat[1:300, ]) |>
step_msc(recipes::all_predictors())
prepped <- recipes::prep(rec)
recipes::bake(prepped, new_data = dat[301:368, ])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.