November 2016
Beginner to intermediate
959 pages
43h 46m
English
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 cylinders, displacement, horsepower, weight, and acceleration variables.
To perform linear regression, follow these steps:
caret package:> library(caret)
> auto <- read.csv("auto-mpg.csv")Read now
Unlock full access