rmgap: Removing vertical gaps in spectra

View source: R/rmgap.R

rmgapR Documentation

Removing vertical gaps in spectra

Description

Remove the vertical gaps in spectra (rows of matrix X), e.g. for ASD. This is done by extrapolation from simple linear regressions computed on the left side of the gaps.

Usage

rmgap(X, indexcol, k = 5)

Arguments

X

A dataset.

indexcol

The column indexes corresponding to the gaps. For instance, if two gaps are observed between indexes 651-652 and between indexes 1451-1452, respectively, then indexcol = c(651, 1451).

k

The number of columns used on the left side of the gaps for fitting the linear regressions.

Value

The corrected data X.

Examples


data(asdgap)
X <- asdgap$X

## Two gaps are at wavelengths 1000-1001 nm and 1800-1801 nm

indexcol <- which(colnames(X) == "1000" | colnames(X) == "1800")
indexcol
plotsp(X, lwd = 1.5)
abline(v = as.numeric(colnames(X)[1]) + indexcol - 1, col = "lightgrey", lty = 3)

zX <- rmgap(X, indexcol = indexcol)
plotsp(zX, lwd = 1.5)
abline(v = as.numeric(colnames(zX)[1]) + indexcol - 1, col = "lightgrey", lty = 3)


mlesnoff/rchemo documentation built on April 15, 2023, 1:25 p.m.