Learn R Programming

ChemoSpec (version 3.0-1)

removeSample: Remove Samples or Groups from a Spectra Object

Description

Removes specified samples from a "Spectra" object.

Usage

removeSample(spectra, rem.sam)
removeGroup(spectra, rem.group)

Arguments

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

Value

  • A modified object of S3 class "Spectra".

Details

If rem.sam or rem.group is a character vector, the sample or group names are grepped for the corresponding values. 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. removeSample removes samples (objects) based upon the sample names. removeGroup removes entire groups based upon the group name. removeGroup will report if it finds extra data elements. These may be per sample data. If so, the user will need to manually edit them using the indices reported to the console.

References

https://github.com/bryanhanson/ChemoSpec

See Also

removeFreq to remove selected frequencies from a "Spectra" object.

Examples

Run this code
data(CuticleIR)
new1 <- removeSample(CuticleIR, rem.sam = 20)
# removes the 20th spectrum/sample
new2 <- removeSample(CuticleIR, rem.sam = "GE")
# removes all samples whose name contains "GE"
new3 <- removeSample(CuticleIR, rem.sam = "GE10")
# removes one spectrum/sample with this exact name.

Run the code above in your browser using DataLab