Ys Kee Ys Kee - 1 year ago 92
R Question

finding point by linear interpolation in R

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)


Answer Source

You just need to specify an xout value.

[1] 5.019802

[1] 0.4509901
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download