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

aggregate_spectra

Aggregates spectral and data information


Description

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

Usage

## S4 method for signature 'Spectra'
aggregate_spectra(obj, fun = mean, ...)

## S4 method for signature 'SpectraDataFrame'
aggregate_spectra(obj, fun = mean, id = NULL, ...)

Arguments

obj

see below

fun

see below

...

see below

id

see below

Details

For SpectraDataFrame objects, associated data is also aggregated using the function provided by the fun option. Additionally, the method for SpectraDataFrame has an id option that allows to specify an attribute which will be used to split the object, apply sequentially the fun function, and recombine the results in an unique object.

Value

An object of the same class as obj

Methods

x=Spectra

aggregate_spectra(obj, fun=mean, ...)

obj A Spectra object
fun An aggregation function
... Expressions evaluated in the context of fun

x=SpectraDataFrame

aggregate_spectra(obj, fun=mean, id=NULL, ...)

obj A SpectraDataFrame object
fun An aggregation function
id Attribute(s) to split the object (character vector)
... Expressions evaluated in the context of fun

Author(s)

Pierre Roudier pierre.roudier@gmail.com

See Also

Examples

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

# Aggregation on the whole collection
m <- aggregate_spectra(australia, fun = mean)
plot(m)

# Aggregation factor-wise

# Generate some kind of factor
australia$fact <- sample(
  LETTERS[1:3], 
  size = nrow(australia), 
  replace = TRUE
)
m <- aggregate_spectra(australia, fun = mean, id = 'fact')
plot(m)

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.