if (checkForPackageWithVersion("ChemoSpec", 6.0)) {
library("ChemoSpec")
data(SrE.IR)
sumSpectra(SrE.IR)
# Examples where rem.freq is a logical vector
# 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
# Examples where rem.freq is a formula
# Remove frequencies from one end:
newIR <- removeFreq(SrE.IR, rem.freq = 3500 ~ high)
# Remove frequencies from both ends is a two step process with formulas:
newIR <- removeFreq(SrE.IR, rem.freq = 3500 ~ high)
newIR <- removeFreq(newIR, rem.freq = low ~ 800)
# Remove frequencies from the middle:
newIR <- removeFreq(SrE.IR, rem.freq = 800 ~ 1000)
# After any of these, inspect the results:
sumSpectra(newIR)
}
if (checkForPackageWithVersion("ChemoSpec2D", 0.5)) {
library("ChemoSpec2D")
# Note we will set contours a bit low to better
# show what is going on.
data(MUD1)
plotSpectra2D(MUD1, which = 7, lvls = 0.1, cols = "black",
main = "MUD1 Sample 7: Complete Data Set")
MUD1a <- removeFreq(MUD1, remF2 = 2.5 ~ 4)
sumSpectra(MUD1a) # don't plot, removing peaks from interior is misleading
MUD1b <- removeFreq(MUD1, remF2 = low ~ 2)
sumSpectra(MUD1b)
plotSpectra2D(MUD1b, which = 7, lvls = 0.1, cols = "black",
main = "MUD1 Sample 7\nRemoved Peaks: F2 low ~ 2")
MUD1c <- removeFreq(MUD1, remF1 = high ~ 23)
sumSpectra(MUD1c)
plotSpectra2D(MUD1c, which = 7, lvls = 0.1, cols = "black",
main = "MUD1 Sample 7\nRemoved Peaks: F1 high ~ 23")
MUD1d <- removeFreq(MUD1, remF2 = 2.5 ~ 4, remF1 = 45 ~ 55)
sumSpectra(MUD1d) # don't plot, removing peaks from interior is misleading
}
Run the code above in your browser using DataLab