Learn R Programming

spectral (version 2.0)

amax: Local Maxima

Description

Determines all local maxima from a real valued vector.

Usage

amax(x)

Arguments

x

numeric vector

Value

returns the indicies of local maxima. If x[1] = max, then it is ignored.

Details

The purpose is to detect all local maxima in a real valued 1D vector. If the first element x[1] is the global maximum, it is ignored, because there is no information about the previous element. If there is a plateau, the first edge is detected.

Examples

Run this code
# NOT RUN {
a <- c(1,2,3,2,1,5,5,4)
amax(a) # 3, 6
# }

Run the code above in your browser using DataLab