Skip to content
Prev 387645 / 398502 Next

local maxima positions in a vector with duplicated values

Your original query included
    > x <- c(1,0,0,0,2,2,3,4,0,1,1,0,5,5,5,0,1)
    ... I need 8 10 13.
Did you also want the 1's at the ends to count as local maxima,
so the result would be c(1,8,10,13,17)?
Or do you want the maxima at endpoints only if there are no others?

-BIll

On Mon, Mar 29, 2021 at 8:56 AM Stefano Sofia
<stefano.sofia at regione.marche.it> wrote: