[R] Interpolate x from y

Greg chaoborid at gmail.com
Wed Mar 25 13:37:41 CET 2009


Forgive me for not being more clear.

> Would you expect that one y
> value returns more than one x? I don't

No, I don't either.  I want to know the value of that x, however.  For
example:

x <- c(2.743, 3.019, 3.329, 3.583, 4.017)
y <- c(0.000, 0.025, 0.025, 0.158, 1.000)

I would like to know the value of x when y is 0.1 and 0.9. If I try to
"trick" approx() to give the answer I'm looking for by switching x & y
(e.g., approx(y, x)) the (perfectly reasonable) warning, "In approx(y,
x, c(0.1, 0.9)) : collapsing to unique 'x' values" is thrown.

I'm simply wondering if it's possible to interpolate to an x-axis--
similar to approx()'s behaviour to interpolate to a y-axis, but in
reverse.

Greg.




More information about the R-help mailing list