step_measure_calibrate_y() creates a specification of a recipe step
that applies a response factor or calibration function to y-axis (value)
values.
Usage
step_measure_calibrate_y(
recipe,
response_factor = 1,
calibration = NULL,
measures = NULL,
role = NA,
trained = FALSE,
cal_fn = NULL,
skip = FALSE,
id = recipes::rand_id("measure_calibrate_y")
)Arguments
- recipe
A recipe object. The step will be added to the sequence of operations for this recipe.
- response_factor
A numeric value to multiply all values by. Default is
1.0(no change). This is a simple scalar calibration.- calibration
An optional calibration function that takes value(s) and returns calibrated value(s). If provided, this takes precedence over
response_factor.- measures
An optional character vector of measure column names to process. If
NULL(the default), all measure columns will be processed.- role
Not used by this step since no new variables are created.
- trained
A logical to indicate if the step has been trained.
- cal_fn
The calibration function to apply (built during prep).
- skip
A logical. Should the step be skipped when baking?
- id
A character string that is unique to this step.
Details
Y-axis calibration is used to convert raw signal intensities to quantitative values. Common examples include:
Chromatography: Apply detector response factors
Spectroscopy: Apply molar absorptivity corrections
Mass spectrometry: Apply ionization efficiency corrections
Simple mode: Use response_factor to multiply all values by a constant.
Complex mode: Use calibration to provide a function for non-linear
calibration curves (e.g., from fitting standards).
No selectors should be supplied to this step function. The data should be
in the internal format produced by step_measure_input_wide() or
step_measure_input_long().
Tidying
When you tidy() this step, a tibble with columns
terms, response_factor, has_calibration, and id is returned.
See also
step_measure_calibrate_x() for x-axis calibration
Other measure-preprocessing:
step_measure_absorbance(),
step_measure_calibrate_x(),
step_measure_derivative(),
step_measure_derivative_gap(),
step_measure_emsc(),
step_measure_kubelka_munk(),
step_measure_log(),
step_measure_map(),
step_measure_msc(),
step_measure_normalize_istd(),
step_measure_osc(),
step_measure_ratio_reference(),
step_measure_snv(),
step_measure_subtract_blank(),
step_measure_subtract_reference(),
step_measure_transmittance()
Examples
library(recipes)
# Simple response factor
rec <- recipe(water + fat + protein ~ ., data = meats_long) |>
update_role(id, new_role = "id") |>
step_measure_input_long(transmittance, location = vars(channel)) |>
step_measure_calibrate_y(response_factor = 2.5)
# With calibration function (e.g., log transform)
rec2 <- recipe(water + fat + protein ~ ., data = meats_long) |>
update_role(id, new_role = "id") |>
step_measure_input_long(transmittance, location = vars(channel)) |>
step_measure_calibrate_y(calibration = function(x) log10(x + 0.001))