View source: R/savitzky_golay.R
| step_savgol | R Documentation |
step_savgol() creates a specification of a recipe step that smooths
the spectra, or computes their derivative, with savitzky_golay().
step_savgol(
recipe,
...,
window = 11,
order = 2,
derivative = 0,
segments = TRUE,
role = NA,
trained = FALSE,
columns = NULL,
skip = FALSE,
id = recipes::rand_id("savgol")
)
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 |
window |
The width of the window, an odd number of channels. Default is 11. |
order |
The degree of the polynomial, smaller than |
derivative |
The derivative: 0 (smoothing, default), 1 or 2. It
must not exceed |
segments |
A logical: filter the segments between gaps of the
wavelength axis separately ( |
role |
Not used by this step, since no new variables are created. |
trained |
A logical indicating whether 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. |
The selected columns form one spectrum per row, and are replaced by the
filtered values. Nothing is estimated from the training data. The
window, order and derivative can be tuned with tune::tune()
(dials parameters window_size(), degree_int() and
savgol_derivative()); an even window, as a tuning grid may propose,
is increased to the next odd number. tidy() returns the
terms, window, order, derivative and id.
An updated version of recipe with the new step added to the
sequence of existing steps.
savitzky_golay(), step_snv()
if (rlang::is_installed("recipes")) {
data(forageLIBS)
rec <- recipes::recipe(K ~ ., data = forageLIBS[-c(1:10, 12:14)]) |>
step_savgol(recipes::all_predictors(), window = 11, derivative = 1) |>
recipes::prep()
recipes::tidy(rec, number = 1)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.