dderiv {rchemo}R Documentation

Derivation by finite difference

Description

Calculation of the first derivatives, by finite differences, of the row observations (e.g. spectra) of a dataset.

Usage

dderiv(X, n = 5, ts = 1)

Arguments

X

X-data (n, p).

n

The number of points (i.e. columns of X) defining the window over wich is calculate each finite difference. The derivation is calculated for the point at the center of the window. Therefore, n must be an odd integer, and be higher or equal to 3.

ts

A scaling factor for the finite differences (by default, ts = 1.)

Value

A matrix of the transformed data.

Examples


data(cassav)

X <- cassav$Xtest

n <- 15
Xp_derivate1 <- dderiv(X, n = n)
Xp_derivate2 <- dderiv(dderiv(X, n), n)

oldpar <- par(mfrow = c(1, 1))
par(mfrow = c(1, 2))
plotsp(X, main = "Signal")
plotsp(Xp_derivate1, main = "Corrected signal")
abline(h = 0, lty = 2, col = "grey")
par(oldpar)


[Package rchemo version 0.1-1 Index]