robust_peaks: Find Peaks and Troughs Robustly (version 3)

View source: R/find_peaks.R

robust_peaksR Documentation

Find Peaks and Troughs Robustly (version 3)

Description

My version, starting from Brian Ripley's and informed by all the others. The previous versions found peaks & toughs, but could get false hits when there was a flat run of the same value. This is not uncommon in testing data, particularly at low speeds and high data sampling rates, where the crosshead can pause at the top or bottom of travel and generate several data points all at the same load/extension.

Usage

robust_peaks(series, span = 5)

Arguments

series

The vector of numbers to find peaks in. Assumed to start low and move towards a peak first.

span

The number of points to check looking for each peak. Must be odd and >= 3. Default is 5.

Details

We solve this by recognising that the starting point must be a trough (as we are moving away from start towards maximum) and that the peaks and troughs must come in strict succession. That is, each peak must be followed by a trough, and so on. Any additional peaks/troughs are false.

This version only works with data that increase away from the start point. That means that compressive tests, where the absolute Load & Extension go negative from the start point, must be inverted before testing for peaks.

Value

A vector of (-1 / 0 / 1) if series[i] is ( trough / "normal" / peak ). Always padded to the length of the input, and awlays starts with a trough.


yadbor/bluer documentation built on Jan. 31, 2023, 7:44 p.m.