1

I have a vector named "ID" which contains 100 values of type "double", you can see its values plotted in the picture:

enter image description here

For all "walks" which would go downhill ( I marked one in purple) I would like to have the values printed into other vectors, basically cut the vector ID at its local maxima and minima. So far, I have the following code snippet:

for (t in 1:100 ){
  if (ID[t] > ID[t+1] && ID[t+1] >= ID[t+2]) {
  adaptivewalk [t] <- ID [t]
  t <- t +1
  } else {
  t <- t+1
}
}

However I am at a loss how to introduce a new vector once I hit a local minima and how, if applicable, I calculate the derivation of this curve in between such local extreme points.

user438383
  • 5,716
  • 8
  • 28
  • 43

0 Answers0