[R] finding peaks in a simple dataset with R

Martin Maechler maechler at stat.math.ethz.ch
Wed Nov 23 14:35:14 CET 2005


I've been asked in private,
(and am replying BCC to the asker),

>> I saw your post on the R-help archives page about the possibility of 
>> porting a function from S-Plus called peaks() to R. I am looking for 
>> some way to locate peaks in a simple x,y data set, and thought that R 
>> might be the way to go.

"of course" it is the way to go, don't get lost be going
somewhere else  :-)
and try

    install.packages("fortune")
    fortune("go with R")

>> Any ideas would be a great help,

Using      RSiteSearch("peaks") gives too many hits, among
which those you can get by the more advanced (regular expression) call

    RSiteSearch("/peaks\\b.*\\bfunction/")

where in the 2nd hit,
    http://finzi.psych.upenn.edu/R/Rhelp02a/archive/33097.html
Petr Pikal gives a simple peaks() function, originally by Brian Ripley
which is using embed() and max.col() smartly.

I wonder if we shouldn't polish that a bit and add to R's
standard 'utils' package.

Martin Maechler, ETH Zurich




More information about the R-help mailing list