R: Remove Groups or Samples from a Spectra Object

removeGroup {ChemoSpec} | R Documentation

## Remove Groups or Samples from a Spectra Object

### Description

Removes specified groups or samples from a `Spectra` object.

### Usage

    removeGroup(spectra, rem.group)

    removeSample(spectra, rem.sam)

### Arguments

`spectra` | An object of S3 class `Spectra`.
`rem.group` | A character vector giving the groups to be removed.
`rem.sam` | Either an integer vector specifying the samples to be removed, or a character vector giving the sample names to be removed.

### Details

Both functions will report if extra data elements are found. These will probably need to be edited manually. The indices reported to the console can be helpful in this regard.

If `rem.sam` is a character vector, the sample names are grepped for the corresponding values. `rem.group` also uses grep. Remember that the grepping process is greedy, i.e. grepping for "XY" find not only "XY" but also "XYZ".

Unused levels in `$groups` are dropped.

### Value

A modified object of S3 class `Spectra`.

### Functions

- `removeGroup`: Remove groups from a `Spectra` object

- `removeSample`: Remove samples from a `Spectra` object

### Author(s)

Bryan A. Hanson, DePauw University.

### References

https://github.com/bryanhanson/ChemoSpec

### See Also

`removeFreq` to remove selected frequencies.

### Examples

    data(metMUD1)

    # removeGroup
    sumSpectra(metMUD1)
    trmt <- removeGroup(metMUD1, rem.group = "Cntrl")
    sumSpectra(trmt)

    # removeSample
    # Removes the 20th spectrum/sample:
    new1 <- removeSample(metMUD1, rem.sam = 20)

    # Removes one spectrum/sample with this exact name:
    new2 <- removeSample(metMUD1, rem.sam = "metMUD1_20")

[Package ChemoSpec version 4.4.97 Index]