dderiv: Derivation by finite difference

View source: R/dderiv.R

dderivR Documentation

Derivation by finite difference

Description

Calculation of the first derivatives, by finite differences, of the row observations (usually spectra) of a data set.

Usage

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

Arguments

X

A n x p matrix or data frame on which are calculated the derivatives.

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.

Examples


data(datcass)

X <- datcass$Xu

n <- 11
zX <- dderiv(X, n)                 # = 1st derivate
#zX <- dderiv(dderiv(X, n), n)     # = 2nd derivate

headm(X)
headm(zX)

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


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