I'm looking for a computationally efficient way to find local maxima/minima for a large list of numbers in R.
Hopefully without for
loops...
For example, if I have a datafile like 1 2 3 2 1 1 2 1
, I want the function to return 3 and 7, which are the positions of the local maxima.