| check4Gaps {ChemoSpec} | R Documentation |
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. A plot of the
gaps is optional.
check4Gaps(x, y = NULL, tol = 0.01, plot = FALSE, silent = FALSE, ...)
x |
A numeric vector to be checked for gaps. |
y |
An optional vector of y-values which correspond to the |
tol |
A number indicating the tolerance for checking to see if the step
between successive |
plot |
Logical indicating if a plot of the gaps should be made. If
|
silent |
Logical indicating a "no gap" condition (return value is
|
... |
Other parameters to be passed to the plot routines if
|
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.
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.freq |
The first frequency value in a given data chunk. |
end.freq |
The last frequency value in a given data chunk. |
size |
The length (in frequency units) of the data chunk. |
beg.indx |
The index of the first frequency value in the data chunk. |
eng.indx |
The index of the last frequency value in the data chunk. |
Bryan A. Hanson, DePauw University.
https://github.com/bryanhanson/ChemoSpec
x <- seq(from = 5, to = 12, by = 0.1) remove <- c(8:11, 40:45); x <- x[-remove] gaps <- check4Gaps(x) data(SrE.IR) newIR <- removeFreq(SrE.IR, rem.freq = SrE.IR$freq > 1800 & SrE.IR$freq < 2500) check4Gaps(newIR$freq, newIR$data[1,], plot = TRUE)