# Whole spectra variance
x1 <-
   ir::ir_sample_data |>
   ir::ir_variance_region(
      subtract_smoothed = FALSE,
      do_normalize = TRUE,
      normalize_method = "area",
      range = NULL
   )
# Spectra variance, but only from a specific region
range <- data.frame(start = 2700, end = 2800)
x2 <-
   ir::ir_sample_data |>
   ir::ir_normalize(method = "area") |>
   ir::ir_variance_region(
      subtract_smoothed = FALSE,
      do_normalize = TRUE,
      normalize_method = "area",
      range = range
   )
# Spectra variance after subtracting a smoothed version of the spectra and
# only from a specific region
x3 <-
   ir::ir_sample_data %>%
   ir::ir_variance_region(
      subtract_smoothed = TRUE,
      do_normalize = FALSE,
      range = range,
      p = 3, n = 31, ts = 1, m = 0
   )
Run the code above in your browser using DataLab