0

Suppose I have a couple of toy dataframes in R:

ToyDF_1 <- as.data.frame(c(12,10,8,10,12,6,10))
ToyDF_2 <- as.data.frame(c(12,10,10,7,12,6,10))

My question is quite simple conceptually, but I haven't been able to find a solution for it. I would like to know how to get the index of the FIRST minimum of these dataframes. So in this case, a way to fetch index 3 in the first dataframe, and 4 in the second.

I do not know beforehand where this first minimum might show up, and the only built-in function that exists in R (which.min) only fetches the row index of the global minimum.

I believe a way out may be to consider differences with regards to the previous element, but not sure how to make it.

VLAZ
  • 26,331
  • 9
  • 49
  • 67
Arrebimbomalho
  • 176
  • 1
  • 12
  • 1
    you are creating vectors and not data frames. The function is `which.min` – missuse Jun 29 '21 at 20:38
  • Yeah, sorry, will edit the question a little bit. Still, I am aware of the which.min() function, but does not return the first, rather the overll, minimum. – Arrebimbomalho Jun 29 '21 at 20:39
  • 2
    [This question](https://stackoverflow.com/q/6836409/10898875) elicited several answers about finding local maxima/minima; can you adapt one of those to find just the first one? (Something like the min index of local minima should do it.) – A. S. K. Jun 29 '21 at 20:42
  • Might have the answer hidden there, indeed. Thanks for the heads up! – Arrebimbomalho Jun 29 '21 at 20:44

0 Answers0