Re: [R] Interpolate x from y

2009-03-25 Thread David Winsemius
On Mar 25, 2009, at 2:22 PM, David Winsemius wrote: 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(

Re: [R] Interpolate x from y

2009-03-25 Thread David Winsemius
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.

Re: [R] Interpolate x from y

2009-03-25 Thread Greg
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 th

Re: [R] Interpolate x from y

2009-03-25 Thread Patrizio Frederic
Greg, it seems an obvious behavior to me y=c(2,2,2,3,3,3,1) x=1:length(y) plot(x,y) lines(x,approxfun(x,y)(x)) # for every x it exists one only value of y plot(y,x) lines(sort(y),approxfun(y,x)(sort(y))) # for some y it exists more than one value of x! approxfun return a function. By definition

[R] Interpolate x from y

2009-03-25 Thread Greg
Is it possible to interpolate a value for x with knowledge of y? For example, approx(x, y, xout) will give me y's given a set of x's, which is opposite to what I'm after. I've tried switching x and y, e.g., approx(y, x, xout), but in a real data set it is possible to have more than one y for a gi