savgol: Savitzky-Golay smoothing

View source: R/savgol.R

savgolR Documentation

Savitzky-Golay smoothing

Description

Smoothing by derivation, with a Savitzky-Golay filter, of the row observations (usually spectra) of a data set .

The function uses function sgolayfilt.

Usage

savgol(X, m, n, p, ts = 1)

Arguments

X

A matrix or data frame. The column names of X must be integers (usually the wavelengths).

m

A derivation order.

n

A filter length (must be odd), i.e. number of colums in matrix X that defines the calculation window.

p

A polynomial order.

ts

A scaling factor (e.g. the step between two wavelengths in matrix X), see argument ts in function sgolayfilt. This has not impact on the form of the output.

Details

savgol uses functions sgolayfilt and sgolay of package signal.

Value

A matrix of the transformed data.

Examples


X <- datcass$Xu

m <- 1 ; n <- 11 ; p <- 3
z <- savgol(X, m, n, p)

headm(X)
headm(z)

oldpar <- par(mfrow = c(1, 1))
par(mfrow = c(1, 2))
plotsp(X, main = "Signal")
plotsp(z, zeroes = TRUE, main = "Corrected signal")
par(oldpar)


mlesnoff/rnirs documentation built on April 24, 2023, 4:17 a.m.