hist_find_peaks.slope | R Documentation |
Find peaks in given histgram. The peaks are devided by the valley which are detected by the sloop.
hist_find_peaks.slope(hist.data, min.ratio = 0.3, min.value = NA, interval = 1)
hist.data |
The target histgram |
min.ratio |
The minmum ratio for being detected as a valley. The ratio is calculated by the min([peaks values in both sides]/[valley value]). |
min.value |
The minmum value for being detected as a valley. |
interval |
The step of the slope. |
Table of the peaks with lower number, upper number, top number (maximum position within the peak) and frequency of each peaks.
hist.data = c(1,5,7,5,5,4,3,1,0,0,0,4,4,8,5,5,5,5,3,3,3,7,7,8,3,3,1,3,5,0,0,2,3,3,0)
peaks = hist_find_peaks.slope(hist.data,0.5)
plot(hist.data,type="b",lwd=2)
for(i in 1:nrow(peaks)){
segments(peaks$top[i],-1,peaks$top[i],10,col="red")
polygon(
c(peaks$lower[i],peaks$lower[i],peaks$upper[i],peaks$upper[i]),c(-1,10,10,-1),
col=rgb(1,0,0,0.2),border=NA
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.