The source of this code is obtained by typing its name at the R prompt. The output is function (x, thresh = 0) { pks <- which(diff(sign(diff(x, na.pad = FALSE)), na.pad = FALSE) < 0) + 2 if (!missing(thresh)) { pks[x[pks - 1] - x[pks] > thresh] } else pks } The test `x[pks - 1] - x[pks] > thresh` compares each peak value to the value *immediately succeeding it* in the series (not to the next trough in the series). It uses a (crude) estimate of the size of the *slope* of the function immediately after the peak and selects only those peaks where that slope exceeds `thresh` in size. In your case, only the first three peaks are sufficiently sharp to pass the test. You will detect all the peaks by using the default: > findPeaks(cc) [1] 3 22 41 59 78 96