[R] peaks

Petr Pikal petr.pikal at precheza.cz
Wed May 29 11:05:04 CEST 2002



On 28 May 2002 at 16:26, Herve Cardot wrote:

> I am looking for a function in R that is  equivalent to the function
> "peaks" in Splus. This function  gives the local maxima of a vector. I
> do not find it using the help and I 'm not sure it exits in R.
> 
> Could someone help me ?
> Thanks,
> 
Here is a function originally based on idea of prof.Ripley (slightly 
modifyed) which shall work like peaks in S+. I did not tested it on 
R 150 but it worked in former versions correctly.

# funkce pro automaticke oznaceni piku ve spektru (peaks)
# autor Brian Ripley

peaks<-function(series,span=3)
{
z <- embed(series, span)
s <- span%/%2
v<- max.col(z) == 1 + s
result <- c(rep(FALSE,s),v)
result <- result[1:(length(result)-s)]
result
}

> Herve Cardot
> 
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
> -.-.-.-.- 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
> _._._._._

Petr Pikal
petr.pikal at precheza.cz
p.pik at volny.cz


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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