# local maxima positions in a vector with duplicated values

11 messages
Open this post in threaded view
|

## local maxima positions in a vector with duplicated values

Open this post in threaded view
|

## Re: local maxima positions in a vector with duplicated values

Open this post in threaded view
|

## Re: local maxima positions in a vector with duplicated values

Open this post in threaded view
|

## Re: local maxima positions in a vector with duplicated values

 In reply to this post by Stefano Sofia Stefano, my contribution is similar to Bill Dunlap's:   x <- c(1,0,0,0,2,2,3,4,0,1,1,0,5,5,5,0,1)   (cumsum(rle(x)\$lengths)-(rle(x)\$length-1))[which(diff(diff(rle(x)\$values)>=0)<0)+1]   cumsum(rle(x)\$lengths)[which(diff(diff(rle(x)\$value)>0)>0)+1] kind of a cute little problem, actually. cheers, Greg ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: local maxima positions in a vector with duplicated values

Open this post in threaded view
|

## Re: local maxima positions in a vector with duplicated values

Open this post in threaded view
|

## Re: local maxima positions in a vector with duplicated values

 Stefano, i notice that my and Bill's (pretty much isomorphic) solutions give a zero-length vector.  i don't remember Bert's, but it's probably gives similar results.  your code could check for that result, and react accordingly. cheers, Greg ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: local maxima positions in a vector with duplicated values

Open this post in threaded view
|