Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. x <- c(5,6)
  2. y <- c(0.45,0.50)
  3.  
  4. interp <- approx(x,y)
  5.  
  6. plot(x,y,pch=16,cex=2)
  7. points(interp,col='red')
  8.  
  9. approx(x,y,xout=5.019802)
  10. $x
  11. [1] 5.019802
  12.  
  13. $y
  14. [1] 0.4509901
  15.  
  16. x = c(5,6)
  17. y = c(0.45, 0.50)
  18. m <- (y[2] - y[1]) / (x[2] - x[1]) # slope formula
  19. b <- y[1]-(m*x[1]) # solve for b
  20. m*(5.019802) + b
  21.  
  22. # same answer as the approx function
  23. [1] 0.4509901
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement