Ys Kee - 3 months ago 33

R Question

I have two points (5,0.45) & (6,0.50)

I need to find the value when x=5.019802 by linear interpolation.

But how to code it in R?

I got code below but just got a graph insdeed.

`x<- c(5,6)`

y<- c(0.45,0.50)

interp<- approx(x,y)

plot(x,y,pch=16,cex=2)

points(interp,col='red')

Answer

You just need to specify an `xout`

value.

```
approx(x,y,xout=5.019802)
$x
[1] 5.019802
$y
[1] 0.4509901
```