data(tea)
tpoints <- as.numeric(rownames(tea.raw[[1]]))
lambdas <- as.numeric(colnames(tea.raw[[1]]))
## limit retention time and wavelength ranges, and do smoothing and
## baseline correction
new.time <- seq(13, 14.1, by = .05)
new.wavelengths <- seq(400, 500, by = 2)
tea.raw1.processed <-
preprocess(tea.raw[[1]], dim1 = new.time, dim2 = new.wavelengths)
plot(tpoints, tea.raw[[1]][,lambdas == 470],
xlim = range(new.time), type = "l", col = "gray",
main = "Chromatogram at 470 nm", xlab = "Time (min.)",
ylab = "")
lines(new.time, tea.raw1.processed[,new.wavelengths == 470], col = "red")
legend("topleft", lty = 1, col = c("gray", "red"), bty = "n",
legend = c("Original data", "Preprocessed data"))
plot(lambdas, tea.raw[[1]][tpoints == 13.7,],
xlim = range(new.wavelengths),
ylim = c(0, max(tea.raw[[1]][tpoints == 13.7,])),
type = "l", col = "gray",
main = "Spectrum at 13.7 min.", xlab = expression(lambda),
ylab = "")
lines(new.wavelengths, tea.raw1.processed[new.time == 13.7,], col = "red")
legend("topleft", lty = 1, col = c("gray", "red"), bty = "n",
legend = c("Original data", "Preprocessed data"))
Run the code above in your browser using DataLab