R: Verify the Integrity of a Spectra Object

chkSpectra {ChemoSpec} | R Documentation

## Verify the Integrity of a Spectra Object

### Description

Utility function to verify that the structure of a `Spectra` object (an S3 object) is internally consistent. This function can be used after manual editting of a `Spectra` object. However, in most cases rather than directly manipulating a `Spectra` object, one should manipulate it via `removeFreq`, `removeGroup` or `removeSample`.

### Usage

    chkSpectra(spectra, confirm = FALSE)

### Arguments

`spectra` | An object of S3 class `Spectra` to be checked.
`confirm` | Logical indicating whether or not to write the results to the console, as would be desirable for interactive use.

### Details

This function is similar in spirit to `validObject` in the S4 world. When used at the console, and the object is OK, no message is written unless `confirm = TRUE`. At the console, if there is a problem, messages are issued regardless of the value of `confirm`. When used in a function, this function is silent (assuming `confirm = FALSE`) unless there is a problem.

### Value

None; messages will be printed at the console if there is a problem.

### Author(s)

Bryan A. Hanson, DePauw University.

### References

https://github.com/bryanhanson/ChemoSpec

### Examples

    data(metMUD1)
    chkSpectra(metMUD1, confirm = TRUE) # OK

    # What's next is the wrong way to manipulate a Spectra object.
    # One should removeSample instead.
    # We won't run during checking as an error is raised

    ## Not run:

    remove <- c(20:40)
    metMUD1$freq <- metMUD1$freq[-remove]
    chkSpectra(metMUD1, confirm = TRUE) # not OK, you didn't listen to me!

    ## End(Not run)

[Package ChemoSpec version 4.4.97 Index]