Learn R Programming

ChemoSpec (version 4.4.97)

removeGroup: 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.

Value

A modified object of S3 class Spectra.

Functions

  • removeGroup: Remove groups from a Spectra object

  • removeSample: Remove samples from a Spectra object

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.

References

https://github.com/bryanhanson/ChemoSpec

See Also

removeFreq to remove selected frequencies.

Examples

Run this code
# NOT RUN {
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")

# }

Run the code above in your browser using DataLab