Skip to contents

step_measure_transmittance() creates a specification of a recipe step that converts absorbance values to transmittance.

Usage

step_measure_transmittance(
  recipe,
  measures = NULL,
  role = NA,
  trained = FALSE,
  skip = FALSE,
  id = recipes::rand_id("measure_transmittance")
)

Arguments

recipe

A recipe object. The step will be added to the sequence of operations for this recipe.

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.

skip

A logical. Should the step be skipped when baking?

id

A character string that is unique to this step.

Value

An updated version of recipe with the new step added.

Details

This step applies the inverse Beer-Lambert law transformation:

$$T = 10^{-A}$$

where \(A\) is absorbance and \(T\) is transmittance.

The measurement locations are preserved unchanged.

Examples

library(recipes)

# Convert to absorbance then back to transmittance (round-trip)
rec <- recipe(water + fat + protein ~ ., data = meats_long) |>
  update_role(id, new_role = "id") |>
  step_measure_input_long(transmittance, location = vars(channel)) |>
  step_measure_absorbance() |>
  step_measure_transmittance() |>
  prep()