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

apply_spectra

Apply a function on the spectra of a Spectra* object


Description

Aggregates spectral and data information of a Spectra object using a user-defined function.

Apply a function and update the spectra of a Spectra object. This function is particularly interesting for pre-processing, e.g to derive the spectra, or apply pre-processing functions such as snv.

Usage

apply_spectra(obj, fun, ...)

Arguments

obj

an object inheriting from class Spectra

fun

an aggregation function

...

expressions evaluated in the context of fun

Details

The philosophy of this function is to let the user free to use any function to pre-process a spectra collection, using either functions from the stats package, functions from other packages such as signal, or personal functions.

Value

An object of the same class as obj

Author(s)

Pierre Roudier pierre.roudier@gmail.com

See Also

Examples

# Loading example data
data(australia)
spectra(australia) <- sr_no ~ ... ~ 350:2500

# Second derivative
r <- apply_spectra(australia, diff, 2)
plot(r)

# Smoothing kernel
k <- kernel("daniell", 20) # define a kernel
r <- apply_spectra(australia, kernapply, k)
plot(r)

## Not run: 
# Savitzky-Golay filter (from the signal package)
library(signal)
r <- apply_spectra(australia, sgolayfilt, n = 33, p = 4)
plot(r)

## End(Not run)

spectacles

Storing, Manipulating and Analysis Spectroscopy and Associated Data

v0.5-3
GPL-3
Authors
Pierre Roudier [aut, cre], Max Kuhn [ctb], Kristian Hovde Liland [ctb], Bjorn-Helge Mevik [ctb], Hadley Wickham [ctb], Raphael Viscarra Rossel [dtc]
Initial release
2021-01-11

We don't support your browser anymore

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