Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

baselineSpectra

Baseline Correction of a Spectra Object


Description

This function mostly wraps functions in package baseline which carries out a variety of baseline correction routines. A simple linear correction method is also available.

Usage

baselineSpectra(spectra, int = TRUE, retC = FALSE, ...)

Arguments

spectra

An object of S3 class Spectra.

int

Logical; if TRUE, do the correction interactively using widgets. No results are saved. Use this for inspection and exploration only.

retC

Logical: shall the baseline-corrected spectra be returned in the Spectra object?

...

Other arguments passed downstream. The relevant ones can be found in baseline. Be sure to pay attention to argument method as you will probably want to use it. You can also use method = "linear" for a simple linear fit, see Details.

Details

In plots using methods from the baseline package, the x axis ticks give the data point index, not the original values from your data. Note that you cannot zoom the non-interactive display of corrected spectra because the underlying function hardwires the display. Try the interactive version instead (int = TRUE), or use plotSpectra on the corrected data. In addition to the methods provided by baseline, you can also use method = "linear". This correction is handled locally, and is very simple: a line is drawn from the first data point to the last, and this becomes the new baseline. This is most suitable for cases in which the baseline rises or falls steadily, as is often seen in chromatograms.

Value

If int = TRUE, an interactive plot is created. If int = FALSE and retC = FALSE, an object of class baseline is returned (see baseline-class). If int = FALSE and retC = TRUE, a Spectra object containing the corrected spectra is returned. In these latter two cases plots are also drawn.

Author(s)

Bryan A. Hanson, DePauw University.

See Also

Additional documentation at https://bryanhanson.github.io/ChemoSpec/

Examples

data(SrE.IR)
temp <- baselineSpectra(SrE.IR, int = FALSE, method = "modpolyfit")

ChemoSpec

Exploratory Chemometrics for Spectroscopy

v5.3.11
GPL-3
Authors
Bryan A. Hanson [aut, cre] (<https://orcid.org/0000-0003-3536-8246>), Mike Bostock [cph, ctb] (author of the d3.js library used by plotSpectraJS, http://d3js.org), Matt Keinsley [ctb] (author of initial AOV-PCA code)
Initial release
2021-03-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.