findPeak: Find peak in a vector

View source: R/process.R

findPeakR Documentation

Find peak in a vector

Description

Find the position of peak in a vector.

Usage

findPeak(x, threshold = 1, length = 4)

Arguments

x

A numeric vector.

threshold

Integer, only values bigger than threshold are recognized as part of the peak.

length

Integer, minimum length of consecutive values bigger than threshold are recognized as a peak.

Value

A numeric vector. The first element is the start index and the second element is the end index of the peak. If multiple peaks exist, only output the start and end index of the one with maximun length. If no peak exist, return c(0, 0).

Examples

# return c(3, 10)
findPeak(c(0:5, 5:0), threshold=1, length=4)

# Most likely return c(0, 0)
findPeak(rnorm(10), threshold=3, length=3)

liuwd15/tomoda documentation built on March 29, 2022, 1:09 a.m.