Here is my experiment:
I am using the
findPeaks function in the quantmod package:
I want to detect "local" peaks within a tolerance 5, i.e. the first locations after the time series drops from the local peaks by 5:
aa=100:1 bb=sin(aa/3) cc=aa*bb plot(cc, type="l") p=findPeaks(cc, 5) points(p, cc[p]) p
The output is
 3 22 41
It seems wrong, as I am expecting more "local peaks" than 3...