[R] Interpolate x from y
David Winsemius
dwinsemius at comcast.net
Wed Mar 25 19:22:51 CET 2009
On Mar 25, 2009, at 8:37 AM, Greg wrote:
> 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.
?lm
?predict
> x <- c(2.743, 3.019, 3.329, 3.583, 4.017)
> y <- c(0.000, 0.025, 0.025, 0.158, 1.000)
> predict(lm(x ~ y))
1 2 3 4 5
3.104855 3.129001 3.129001 3.257457 4.070686
>
>
> 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.
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list