Hi.
My apologies if this has already been covered elsewhere. I did a search on
the S-News archive but couldn't see an answer...
We are trying to use the approx function to interpolate between x values and
pick out the x value corresponding to a particular y reference value.
Here are the data points.
y <- c(0.0000000, -0.5102510, -0.9052479, -1.0896528, -1.3008243,
-1.4873214, -1.6317308, -1.2785499, -1.2571634, -1.1788188, -0.9560946,
0.6101922)
x <- (1:12)
The problem with this seems to be that if the y values are non-monotonic
then using approx(y,x,-1) doesn't give sensible results (since it orders y
smallest to largest, really twisting the order of x). Does anyone have any
advice that would help us to do simple linear interpolation in this case?
It appears that the approx function just won't help in this situation...
Any help would be gladly recieved.
Best regards,
Mike
|