| removeFreq {ChemoSpec} | R Documentation |
This function removes specified frequencies from a Spectra
object. For instance, one might want to remove regions lacking any useful
information (to reduce the data size), or remove regions with large
interfering peaks (e.g. the water peak in 1H NMR).
removeFreq(spectra, rem.freq)
spectra |
An object of S3 class |
rem.freq |
A valid R statement describing the frequencies to be
removed. This must comply with |
rem.freq can be any valid R statement that leads to a vector of
logicals. In the examples below, the | and & operators seem backward in
a sense, but R evaluates them one at a time and combines the result to
give the required output.
An object of S3 class Spectra.
Bryan A. Hanson, DePauw University.
https://github.com/bryanhanson/ChemoSpec
data(SrE.IR) sumSpectra(SrE.IR) # Remove frequencies from one end: newIR <- removeFreq(SrE.IR, rem.freq = SrE.IR$freq > 3500) # Remove frequencies from both ends at once: newIR <- removeFreq(SrE.IR, rem.freq = SrE.IR$freq > 3500 | SrE.IR$freq < 800) # Remove frequencies from the middle: newIR <- removeFreq(SrE.IR, rem.freq = SrE.IR$freq > 800 & SrE.IR$freq < 1000) # The logic of this last one is as follows. Any values # that are TRUE will be removed. values <- 1:7 values > 2 values < 6 values > 2 & values < 6 # After any of these, inspect the results: sumSpectra(newIR) check4Gaps(newIR$freq, newIR$data[1,], plot = TRUE)