Learn R Programming

ChemoSpec (version 2.0-2)

removeFreq: Remove Frequencies from a Spectra Object

Description

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).

Usage

removeFreq(spectra, rem.freq)

Arguments

Value

An object of S3 class "Spectra".

Details

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 some sense, but R evaluates them one at a time and combines the result to give the required output.

References

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

Examples

Run this code
data(CuticleIR)
sumSpectra(CuticleIR) # note the frequency range & existing gap
# remove frequencies from one end:
newIR <- removeFreq(CuticleIR, rem.freq = CuticleIR$freq > 3500)
# remove frequencies from both ends at once:
newIR <- removeFreq(CuticleIR, rem.freq = CuticleIR$freq > 3500
| CuticleIR$freq < 800)
# remove frequencies from the middle:
newIR <- removeFreq(CuticleIR, rem.freq = CuticleIR$freq > 800
& CuticleIR$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)

Run the code above in your browser using DataLab