| ir_smooth | R Documentation | 
ir objectir_smooth applies smoothing functions to infrared spectra.
ir_smooth either performs Savitzky-Golay smoothing, using on
signal::sgolayfilt(), or Fourier smoothing using
fda::smooth.basis(). Savitzky-Golay smoothing can
also be used to compute derivatives of spectra.
ir_smooth(
  x,
  method = "sg",
  p = 3,
  n = p + 3 - p%%2,
  ts = 1,
  m = 0,
  k = 111,
  ...
)
x | 
 An object of class   | 
method | 
 A character value specifying which smoothing method to apply.
If   | 
p | 
 An integer value representing the filter order (i.e. the degree of
the polynom) of the Savitzky-Golay filter if   | 
n | 
 An odd integer value representing the length (i.e. the number of
wavenumber values used to construct the polynom) of the Savitzky-Golay filter
if   | 
ts | 
 time scaling factor. See   | 
m | 
 An integer value representing the mth derivative to compute. This
option can be used to compute derivatives of spectra. See
  | 
k | 
 A positive odd integer representing the number of Fourier basis
functions to use as smoothed representation of the spectra if
  | 
... | 
 additional arguments (ignored).  | 
When x contains spectra with different wavenumber values, the
filters are applied for each spectra only on existing wavenumber values. This
means that the filter window (if method == "sg") will be different for
these different spectra.
x with smoothed spectra.
#' # Savitzky-Golay smoothing
if(! requireNamespace("signal", quietly = TRUE)) {
  x1 <-
     ir::ir_sample_data[1:5, ] |>
     ir::ir_smooth(method = "sg", p = 3, n = 51, ts = 1, m = 0)
}
# Fourier smoothing
if(! requireNamespace("fda", quietly = TRUE)) {
  x2 <-
     ir::ir_sample_data[1:5, ] |>
     ir::ir_smooth(method = "fourier", k = 21)
}
# computing derivative spectra with Savitzky-Golay smoothing (here: first
# derivative)
if(! requireNamespace("signal", quietly = TRUE)) {
  x3 <-
     ir::ir_sample_data[1:5, ] |>
     ir::ir_smooth(method = "sg", p = 3, n = 51, ts = 1, m = 1)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.