Learn R Programming

hyperSpec (version 0.100.2)

collapse: Collapse hyperSpec objects

Description

collapse/bind several hyperSpec objects into one object

Usage

collapse(
  ...,
  wl.tolerance = hy.getOption("wl.tolerance"),
  collapse.equal = TRUE
)

Value

a hyperSpec object

Arguments

...

hyperSpec objects to be collapsed into one object. Instead of giving several arguments, a list with all objects to be collapsed may be given.

wl.tolerance

tolerance to decide which wavelengths are considered equal.

collapse.equal

logical indicating whether to try first finding groups of spectra with (approximately) equal wavelength axes. If the data is known to contain few or no such groups, collapse() will be faster with this first pass being turned off.

Author

C. Beleites

Details

The spectra from all objects will be put into one object. The resulting object has all wavelengths that occur in any of the input objects, wl.tolerance is used to determine which difference in the wavelengths is tolerated as equal: clusters of approximately equal wavelengths will span at most 2 * wl.tolerance. Differences up to +/- wl.tolerance are considered equal.

The returned object has wavelengths that are the weighted average (by number of spectra) of the wavelengths within any such cluster of approximately equal wavelengths.

Labels will be taken from the first object where they are encountered. However, the order of processing objects is not necessarily the same as the order of objects in the input: collapse first processes groups of input objects that share all wavelengths (within wl.tolerance).

Data points corresponding to wavelengths not in the original spectrum will be set to NA. Extra data is combined in the same manner.

If the objects are named, the names will be preserved in extra data column $.name. If the wavelengths are names, names are preserved and taken from the first object where they were encountered, the same applies to possible column names of the spectra matrix.

See Also

Examples

Run this code
barbiturates [1:3]
collapse (barbiturates [1:3])

a <- barbiturates [[1]]
b <- barbiturates [[2]]
c <- barbiturates [[3]]

a
b
c
collapse (a, b, c)

collapse (barbiturates [1:3], collapse.equal = FALSE)

Run the code above in your browser using DataLab