Learn R Programming

ChemoSpec (version 4.4.97)

sgfSpectra: Apply Savitzky-Golay filters to a Spectra object

Description

This function is a simple wrapper around the function sgolayfilt. It allows one to apply Savitzky-Golay filters to a Spectra object in a convenient way.

Usage

sgfSpectra(spectra, m = 0, ...)

Arguments

spectra

An object of S3 class Spectra to be checked.

m

The desired m-th derivative. m = 0 smooths the data (i.ei a rolling average), m = 1 gives the first derivative etc.

Other parameters to be passed to sgolayfilt.

Value

A object of class Spectra.

References

https://github.com/bryanhanson/ChemoSpec

Examples

Run this code
# NOT RUN {
  data(SrE.IR)
  myt1 <- expression(bolditalic(Serenoa)~bolditalic(repens)~bold(IR~Spectra))
  myt2 <- expression(bolditalic(Serenoa)~bolditalic(repens)~bold(IR~Spectra~(Smoothed)))

  par(mfrow = c(2, 1))
  plotSpectra(SrE.IR, xlim = c(1900, 2100), yrange = c(0, 0.05), main = myt1)
  temp <- sgfSpectra(SrE.IR)
  plotSpectra(temp, xlim = c(1900, 2100), yrange = c(0, 0.05), main = myt2)
  par(mfrow = c(1, 1))

# }

Run the code above in your browser using DataLab