detect.peak: detect.peak

Description Usage Arguments Value Examples

View source: R/utils.R

Description

Detect peaks by identifying local maxima/minima in a rolling window.

Usage

1
detect.peak(x, window.size, what = "maxi")

Arguments

x

numerical vector

window.size

integer, width of rolling window.

what

character indicating whether maxima or minima should be looked for. One of c('maxi', 'mini').

Value

A logical vector. TRUE indicates a local maxima/minima. NAs are padded at the extremeties to keep same length as x.

Examples

1
2
3
4
x <- sin(seq(0,25,0.1))
plot(x)
abline(v = which(detect.peak(x, 7, "maxi")), col = 'red', lty = 'dashed')
abline(v = which(detect.peak(x, 7, "mini")), col = 'blue', lty = 'dashed')

majpark21/TSexploreR documentation built on Oct. 16, 2019, 2:46 p.m.