In R, I have a matrix M of the form
lower upper value
0.1 0.2 1.2
0.2 0.3 2.4
0.3 0.4 -0.3
And a vector v with values in (0,1). For each value in v, I want to find the corresponding row in M such that the value is between the 'lower' and 'upper' values in that row, and get the corresponding number from the value column. The output should be a vector y of the same length as v where each element of y is the relevant 'value' as described above. How should I do this? I know I need to use the apply function but can't think of the most efficient way.
For example: For the M above, suppose v = c(0.12, 0.34). Then the expected output is y = c(1.2, -0.3)