I have a bunch of ordered vectors containing numbers from 0 to 1. I need to find the index of the first element over some r value:
x <- c(0.1, 0.3, 0.4, 0.8) which.max(x >= 0.4) [1] 3
Now, if my target value exceeds the maximum value in the vector, which.max () returns 1, which can be confused with the "real" first value:
which.max(x >= 0) [1] 1 which.max(x >= 0.9)
How can I change this expression to get NA as a result?
source share