I have a sorted vector
m<-c(1.1, 3.2, 3.6, 4, 4.6, 4.6, 5.6, 5.7, 6.2, 8.9)
I want to find the position of a value based on an approximate match. If the value does not exist in the vector, I would like the position of the immediately previous value
for exact match I would use
> match(4,m)
[1] 4
But if I do
> match(6,m)
[1] NA
What I would like to get in this example is 8(the position of the minimum previous value of 6, which is the position of 5.7, which is 8 )
Thank you in advance
source
share