View source: R/SavitzkyGolay.R
SavitzkyGolay | R Documentation |
Savitzky-Golay filtering and derivatives
SavitzkyGolay(
X,
poly = 3,
width = 11,
deriv = 2,
ends = c("cut", "extrapolate", "zeros")
)
X |
|
poly |
Polynomial degree of smoother. |
width |
Window width of smoother, default = 11, must be an odd number. |
deriv |
Derivative degree, can be 0, default = 2. |
ends |
Handling of spectrum ends, i.e. first and last (width-1)/2 points. Default is "cut", i.e. remove ends, "extrapolate" copies the first/last estimable point, while "zeros" is included for backward compatilibity (fill with 0). |
A matrix of filtered spectra (possibly with derivatives)
data(fishoil)
Raman <- fishoil$Raman[, 850:3300]
SavGol <- SavitzkyGolay(Raman)
old.par <- par(mfrow = c(2,1), mar = c(4,4,1,1))
matplot(colnames(Raman), t(Raman), type = 'l',
ylab = 'Relative intensity', xlab = 'Raw spectra')
matplot(colnames(SavGol), t(SavGol), type = 'l',
ylab = 'Relative intensity', xlab = 'Smoothed 2nd derivative')
par(old.par)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.