Learn R Programming

ChemometricsWithR (version 0.1.13)

pick.peaks: Peak-picking function.

Description

Function to identify local maxima in a vector, typically a spectrum or a chromatogram.

Usage

pick.peaks(x, span)

Arguments

x

Numerical vector.

span

Neighbourhood, used to define local maxima.

Value

A vector containing positions of local maxima in the input data.

Examples

Run this code
# NOT RUN {
if (require("ptw")) {
data(lcms, package = "ptw")
plot(lcms[1,,1], type = "l", xlim = c(1000, 1500))
abline(v = pick.peaks(lcms[1,,1], 20), col = "blue")
} else {
  cat("Package ptw not available.\nInstall it by typing 'install.packages(\"ptw\")'")
}
# }

Run the code above in your browser using DataLab