Learn R Programming

ChemoSpec (version 2.0-2)

check4Gaps: Check for Missing Values (Gaps)

Description

This function may be used with a Spectra object to see if there are any gaps or discontinuities in the frequency axis. Gaps may arise when unwanted frequencies are removed (e.g, water peaks in 1H NMR, or uninteresting regions in any kind of spectroscopy). As written, it can be used to check for gaps in any appropriate numeric vector. Not normally called directly by the user, but may be (see examples). A plot of the gaps is optional.

Usage

check4Gaps(x, y = NULL, tol = 0.01, plot = FALSE,
	silent = FALSE, ...)

Arguments

Value

A data frame giving the data chunks found, with one chunk per line. Also a plot if requested. In the event there are no gaps found, FALSE is returned.beg.freqThe first frequency value in a given data chunk.end.freqThe last frequency value in a given data chunk.sizeThe length (in frequency units) of the data chunk.beg.indxThe index of the first frequency value in the data chunk.eng.indxThe index of the last frequency value in the data chunk.

Rdversion

1.1

Details

The basic procedure is to compare x[n + 1] - x[n] for successive values of n. When this value jumps, there is a gap which is flagged. beg.indx and end.indx will always be contiguous as indices must be; it is the x values that jump or have the gap. The indices are provided as they are more convenient in some programming contexts. If not assigned, the result appears at the console.

References

http://academic.depauw.edu/~hanson/ChemoSpec/ChemoSpec.html

Examples

Run this code
x <- seq(from = 5, to = 12, by = 0.1)
remove <- 40:45; x <- x[-remove]
check4Gaps(x) # really simple
gaps <- check4Gaps(x) # save the result for later use
data(CuticleIR) # has a gap, let's find it and display it
check4Gaps(CuticleIR$freq, CuticleIR$data[1,], plot = TRUE)

Run the code above in your browser using DataLab