x <- c(-2, -1, -0.8, -0.3, 0, 0.5, 0.6, 0.7, 1, 1.2) y <- c(1.9, 0.6, 0.5, 0.8, -0.4, -0.9, -0.7, -0.1, -1.7, -0.2) fm <- lm(y ~ x) plot(x, y, xlim = c(-3, 3), ylim = c(-3, 3), pch = 19) fitted.values(fm) ## 1 2 3 4 5 6 ## 1.68080699 0.82613011 0.65519474 0.22785630 -0.02854677 -0.45588521 ## 7 8 9 10 ## -0.54135290 -0.62682058 -0.88322365 -1.05415902 residuals(fm) ## 1 2 3 4 5 6 ## 0.2191930 -0.2261301 -0.1551947 0.5721437 -0.3714532 -0.4441148 ## 7 8 9 10 ## -0.1586471 0.5268206 -0.8167764 0.8541590 plot(x, y, xlim = c(-3, 3), ylim = c(-3, 3), pch = 19) abline(fm, col = "red")