Description Usage Arguments Value See Also Examples
Seeks first local maximum starting from the right hand side of given vector and moving towards left hand side.
1 | left.max(v)
|
v |
numeric vector |
numeric value of first local maximum in v
starting from the end of v and going left; NA if v is nonincresing starting at last element of v and going left (i.e. v is either constant or there is minmum first)
local.min
, local.max
for finding local minma and maxima in vector v
1 2 3 4 5 6 7 8 9 10 11 12 | # maximum in 7 (index 2) starting from 1 (index 8) and moving with decreasing indices
v1 <- c(5,6,7,6,4,3,2,1)
# no maximum or minimum
v2 <- c(2,2,2,2,2,2)
# minimum at 2 (index 3) and no maximum starting at 6 (index 7)
v3 <- c(4,3,2,3,4,5,6)
# starting from rightmost element (3 with index 14) and going left, minimum first (in -3, index 9) then maximum (in 6, index 4)
v4 <- c(3,4,5,6,4,3,2,-1,-3,-2,0,1,2,3)
print(left.max(v1))
print(left.max(v2))
print(left.max(v3))
print(left.max(v4))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.