## Plotting a regression line

All of us have studied regressions or at least heard about them in newspapers or journal articles. Regression lines are a visual representation of the regression equation. Gareth, Witten, Hastie, and Tibshirani in the book *An Introduction to Statistical Learning*, have defined a simple linear regression as, "*it is a very straightforward approach for predicting a quantitative response Y on the basis of a single predictor variable X. It assumes that there is approximately a linear relationship between X and Y"*. Readers should refer to chapter 3 of that book to learn the concept of linear regression and its application using R.

From the preceding plot, we observe that horsepower has a negative relationship with miles per gallon (mpg).

### How to do it…

We will first load our data using the `ISLR`

package. We are loading the package to use the data file and this is not required if you would like to use your own imported data:

install.packages("ISLR") library(ISLR)

To generate...