Skip to content
Prev 174854 / 398503 Next

Interpolate x from y

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 a function maps one value
of domain into one only value of codomain. Would you expect that one y
value returns more than one x? I don't
Be more specific and maybe we can help you

Patrizio

2009/3/25 Greg <chaoborid at gmail.com>: