[R] Using "R" to find peaks in sampled data

Martin Maechler maechler at stat.math.ethz.ch
Tue May 29 16:58:50 CEST 2001

>>>>> "Bill" == Bill Simpson <wsi at gcal.ac.uk> writes:

    >>  In any case, I have some sampled data that has peaks, and I would
    >> like to extract peak height, location, and width, according to
    >> almost any statistical model.  Gaussian would seem to make the most
    >> sense.
    Bill> Be specific about the form of your data.  Do you mean that you
    Bill> have a single variable you measured, and you are talking about
    Bill> peaks of some histogram of the data? Or do you have x,y data? If
    Bill> the latter, the peak height is just max(y), and the location is
    Bill> x[y==max(y)].

where you might want to use

      imax <- which.max(y)

    Bill>  The width is not too hard; I have a function that finds the FWHM.

which reminds me that S-plus has a function  peaks() 
that some folks have wanted for R.  If anyone has good code,
not stolen from S-plus, but still compatible,  please post...

Martin Maechler <maechler at stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list