find_peaks: find_peaks

Description Usage Arguments Value Examples

View source: R/General.R

Description

Find Peaks in a timeseries. Credit: https://github.com/stas-g

Usage

1
find_peaks(x, m = 3)

Arguments

x

(numeric) A vector object

m

(numeric) A steepness of slope numeric as a threshold for calculating peaks. The larger the number the fewer the peaks meeting the criteria.

Value

(numeric)

A numeric vector of exact indices of peaks.

Note: this differs from quantmod::findPeaks in that is supplies the indices of the exact peaks, whereas quantmod supplies the vector of indices lagged by one time unit - useful when selling a stock but not if you want to know the exact peak locations.

Examples

1
2
dat <- data.frame(y = rnorm(15,0,1),x = {rnorm(15,0,1) + rnorm(15,0,.02)})
apply(dat, 2, find_peaks)

yogat3ch/HDA documentation built on Sept. 13, 2019, 8:54 p.m.