averageSpectra: Function to average spectra.

Description Usage Arguments Value Author(s) Examples

View source: R/averageSpectra.R

Description

This function accepts spectra, averages them, and returns the results. This function is a simple wrapper for the aggregate() function, made to work smoothly with spectra.

Usage

1

Arguments

spec

An object of class spectra.list or spectra.matrix.

by

Either (i) a vector of length nrow(spec) that specifies which combinations of spectra to average together, or (ii) a single numeric value specifying how many scans to combine, in order. Using the former option, the mean spectra will be named according to the values of by. For the latter option, they will be named in order numerically.

Value

Returns an object of class spectra.matrix.

Author(s)

Daniel M Griffith

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
data(shootout)
by_vector <- gsub(pattern = "_.*",replacement = "", 
 x = row.names(shootout_scans)) # average everything to one scan
mean_scans <- averageSpectra(spec = shootout_scans, by = by_vector)
#or...
mean_scans <- averageSpectra(spec = shootout_scans, by = 3) 
# average scans in groups of 3
par(mfrow=c(1,2))
plot(shootout_scans)
plot(mean_scans)

## End(Not run)

griffithdan/plantspec documentation built on May 17, 2019, 8:37 a.m.