Description Usage Arguments Value Examples

Translated from the Python version at https://github.com/demotu/BMC License: MIT Version: 1.0

1 2 | ```
detect_peaks(x, mph = NA, mpd = 1, threshold = 0, edge = "rising",
kpsh = FALSE, valley = FALSE, mpd_from_start = TRUE)
``` |

`x` |
1-d array |

`mph` |
(NA, number), optional (default = NA). Detect peaks wthat are greater than minimum peak height (if |

`mpd` |
positive integer, optional (default = 1). Detect peaks that are at least separated by minimum peak distance (in number of data) |

`threshold` |
positive number, optional (default = 0). Detect peaks (valleys) that are greater (smaller) than |

`edge` |
One of NA, |

`kpsh` |
Boolean, optional (default = FALSE). Keep peaks with same height even if they are closer than |

`valley` |
Boolean, optional (default = FALSE). If TRUE, detect valleys (local minima) instead of peaks (local maxima) |

`mpd_from_start` |
Boolean (default = TRUE) Should we start counting from beginning, or compute from highest peak (FALSE) |

a 1-d array with indices of the peaks in `x`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ```
x = rnorm(100)
x[60:81] = NA
# detect all peaks and plot data
ind = detect_peaks(x, show=TRUE)
print(ind)
x = sin(2*pi*5*seq(0,1,length.out=200)) + rnorm(200)/5
# set minimum peak height = 0 and minimum peak distance = 20
detect_peaks(x, mph=0, mpd=20, show=TRUE)
x = c(0, 1, 0, 2, 0, 3, 0, 2, 0, 1, 0)
# set minimum peak distance = 2
detect_peaks(x, mpd=2, show=TRUE)
x = sin(2*pi*5*seq(0, 1, length.out=200)) + rnorm(200)/5
# detection of valleys instead of peaks
detect_peaks(x, mph=-1.2, mpd=20, valley=True, show=True)
x =c(0, 1, 1, 0, 1, 1, 0)
# detect both edges
detect_peaks(x, edge='both', show=TRUE)
x =c(-2, 1, -2, 2, 1, 1, 3, 0)
# set threshold = 2
detect_peaks(x, threshold = 2, show=TRUE)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.