How can I find the first element and index of the element of a vector which is smaller than its previous element and it is smaller than its next element in R?
for example, we have a vector like this:
x=c(100.5, 99, 98.5,95.2,110, 116, 120,130)
I would like to find 95.2 and index of this element in R.