| ir_variance_region {ir} | R Documentation |
Computes the variance of a spectrum in an ir object in a given region
Description
ir_variance_region takes a spectrum x and, depending on the
arguments computes the following summary:
- if
subtract_smoothed = FALSE it computes the variance of the intensity values for each spectrum in
x. If in additionrangeis notNULL, it computes the variance only for the region(s) represented byrange.- if
subtract_smoothed = TRUE it smoothes
x, subtracts the smoothedxfrom the unsmoothedxand computes the variance of the difference intensity values. If in additionrangeis notNULL, it computes the variance only for the region(s) represented byrange.
Usage
ir_variance_region(
x,
subtract_smoothed = FALSE,
do_normalize = FALSE,
normalize_method,
...,
range = NULL
)
Arguments
x |
An object of class |
subtract_smoothed |
A logical value. If |
do_normalize |
A logical value. If set to |
normalize_method |
See |
... |
Arguments passed to |
range |
See |
Value
x with two additional columns:
- variance
A numeric vector with the computed variances of the intensity values for the respective spectra.
- n_variance
An integer vector with the number of intensity values used during computing the variance.
Examples
# 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
)