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>:
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 given x causing approx() to remove coordinates. Thanks for your help, Greg.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.