In this recipe, we discuss linear regression, arguably the most widely used technique. The
stats package has the functionality for linear regression and R loads it automatically at startup.
If you have not already done so, download the data files for this chapter and ensure that the
auto-mpg.csv file is in your R working directory. Install the
caret package if you have not already done so. We want to predict
mpg based on
To perform linear regression, follow these steps:
> auto <- read.csv("auto-mpg.csv")