View source: R/line_intensities.R
| step_line_intensities | R Documentation |
step_line_intensities() creates a specification of a recipe step
that replaces the spectral columns by the intensities of selected
emission lines, measured with line_intensities().
step_line_intensities(
recipe,
...,
lines,
half_width = 0.15,
search = 0.2,
method = "area",
baseline = FALSE,
prefix = "line_",
keep_original_cols = FALSE,
role = "predictor",
trained = FALSE,
columns = NULL,
skip = FALSE,
id = recipes::rand_id("line_intensities")
)
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 |
lines |
The lines: a numeric vector of wavelengths (nm), preferably
named, such as |
half_width |
The half-width of the integration window around the peak, in nm. Default is 0.15. |
search |
The half-width of the window in which the peak is searched around the tabulated wavelength, in nm. Default is 0.2. |
method |
|
baseline |
A logical: subtract a linear baseline under each line
( |
prefix |
The prefix of the new column names. Default is |
keep_original_cols |
A logical: keep the spectral columns ( |
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 their names must be
their wavelengths (in nm). Each line becomes a new column, named by
prefix and the name of the line (or its wavelength). Nothing is
estimated from the training data. The Voigt method of
line_intensities() is not offered, as it is too slow for resampling.
tidy() returns the line names, their
wavelength, the method and id.
An updated version of recipe with the new step added to the
sequence of existing steps.
line_intensities(), step_line_ratio()
if (rlang::is_installed("recipes")) {
data(forageLIBS)
rec <- recipes::recipe(K ~ ., data = forageLIBS[-c(1:10, 12:14)]) |>
step_line_intensities(recipes::all_predictors(),
lines = c(K = 769.90, Mg = 285.21, Ca = 317.93)) |>
recipes::prep()
head(recipes::bake(rec, new_data = NULL))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.