# [R] Linear interpolation to calculate x when y=0

From: Daniel Halligan <daniel.halligan_at_ed.ac.uk>
Date: Fri 27 Oct 2006 - 15:56:50 GMT

I have approximated a function y = f(x) by sampling at different values of x. The curve produced by joining up the points crosses y=0 zero at two points, which are within the range of x values sampled and I would like to estimate (approximately) the x values at these points. I think this is best done using linear interpolation, but I am stuck as how to do this.

Here is a data.frame containing the y and x values. data.frame(x = c(0.00000, 0.00010, 0.00100, 0.01000, 0.02404,

```0.07603, 0.10000, 0.12021, 0.15146, 0.19083, 0.24007, 0.24043,
0.24049, 0.30292, 0.38166, 0.48086, 0.76031, 1.00000, 2.00000,
2.40430), y=c(-10.173, -5.046, -2.691, -0.093, 0.791, 1.643, 1.782,
1.858, 1.933, 1.982, 2.000, 2.000, 2.000, 1.980, 1.913, 1.786, 1.318,
0.866, -0.846, -1.397))

```

Any help greatly appreciated.

Dan Halligan

(P.S. I posted a similar question earlier, I hope this is simpler and better phrased)

R-help@stat.math.ethz.ch 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. Received on Sat Oct 28 05:21:36 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 27 Oct 2006 - 20:30:45 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.