R: Remove Frequencies from a Spectra Object

removeFreq {ChemoSpec} | R Documentation

## 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

`spectra` | An object of S3 class `Spectra` from which to remove selected frequencies.
`rem.freq` | A valid R statement describing the frequencies to be removed. This must comply with `Comparison` and `Logic`. See the examples below for common usage.

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

### Value

An object of S3 class `Spectra`.

### Author(s)

Bryan A. Hanson, DePauw University.

### References

https://github.com/bryanhanson/ChemoSpec

### Examples

    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)

[Package ChemoSpec version 4.4.97 Index]