Learn R Programming

hyperSpec (version 0.98-20110927)

merge: Merge hyperSpec objects...

Description

Merge hyperSpec objects

Usage

## S3 method for class 'hyperSpec,hyperSpec':
merge(x, y, ..., short="merge", user=NULL, date=NULL)

Arguments

x
a hyperSpec object
y
a hyperSpec object
...
short,user,date
handed to logentry

Details

Merges two hyperSpec objects and cbinds their spectra matrices.

After merging, the spectra matrix can contain duplicates, and is not ordered according to the wavelength.

If the wavelength axis should be ordered, use orderwl.

See Also

merge.

collapse combines hyperSpec objects that do not share the wavelength axis. rbind, and cbind for combining hyperSpec objects that.

Examples

Run this code
merge (chondro [1:10,, 600], chondro [5:15,, 600], by = c("x", "y"))$.
tmp <- merge (chondro [1:10,, 610], chondro [5:15,, 610],
by = c("x", "y"), all = TRUE)
tmp$.
wl (tmp)
stopifnot (nrow (merge (chondro [1:10], chondro [5:15], all = TRUE)) == 15)
stopifnot (nrow (merge (chondro [1:10], chondro [5:15])) == 6)

## remove duplicated wavelengths:
approxfun <- function (y, wl, new.wl){
approx (wl, y, new.wl, method = "constant",
ties = function (x) mean (x, na.rm = TRUE)
)$y
}

merged <- merge (chondro [1:7,, 610 ~ 620], chondro [5:10,, 615 ~ 625], all = TRUE)
merged$.
merged <- apply (merged, 1, approxfun, 
wl = wl (merged), new.wl = unique (wl (merged)), 
new.wavelength = "new.wl")
merged$.

Run the code above in your browser using DataLab