findPeaks | R Documentation |
A bare-bones, very fast function to find local maxima (peaks) in a numeric vector.
findPeaks(x, wl = 3, thres = NULL)
x |
numeric vector |
wl |
rolling window over which we look for maxima: central value ± floor(wl/2), eg ±1 if wl=3 |
thres |
required absolute value of each peak |
Returns a vector with indices of local maxima
findInflections
x = rnorm(100)
findPeaks(x, wl = 3)
findPeaks(x, wl = 3, thres = 1)
findPeaks(x, wl = 5)
idx = findPeaks(x, wl = 5, thres = 1)
plot(x, type = 'b'); abline(h = 1, lty = 3)
points(idx, x[idx], col = 'blue', pch = 8)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.