Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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')
- approx(x,y,xout=5.019802)
- $x
- [1] 5.019802
- $y
- [1] 0.4509901
- x = c(5,6)
- y = c(0.45, 0.50)
- m <- (y[2] - y[1]) / (x[2] - x[1]) # slope formula
- b <- y[1]-(m*x[1]) # solve for b
- m*(5.019802) + b
- # same answer as the approx function
- [1] 0.4509901
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement