Nikolas Giagtzoglou
October 26th, 2014
For example:
plot(mpg~wt, mtcars)
z<-lm(mpg~wt, mtcars)
print(rbind(c("Intercept:", "Slope:"), as.numeric(round(z$coefficients,2))))
[,1] [,2]
[1,] "Intercept:" "Slope:"
[2,] "37.29" "-5.34"
http://nikolas.shinyapps.io/calculate_linear_fit_coeffcients_in_cars_dataset
Many thanks to Scientificdata for the inspiration!