[R] code for peaks

About this list Date view Thread view Subject view Author view

From: Matthew Wiener (mcw@ln.nimh.nih.gov)
Date: Sat 16 Jun 2001 - 07:06:59 EST


Message-ID: <Pine.LNX.4.21.0106151410100.23542-100000@ln.nimh.nih.gov>

Hi, all.

Andy Liaw (and one other person, whose name I already lost) pointed out to
me that this was answered on the list a few weeks ago. Petr Pikal posted
code based on an idea from Brian Ripley:

peaks <- function(series, span=3){
        z <- embed(series, span)
        result <- max.col(z) == 1 + span %/% 2
        result
}

Somehow I missed this when searching before I posted.

Matt Wiener

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view

This archive was generated by hypermail 2b30 : Fri 22 Jun 2001 - 18:58:45 EST