We'll once again use the
lm() function to fit linear regression models to our data. For both of our datasets, we'll want to use all the input features that remain in our respective data frames. R provides us with a shorthand to write formulas that include all the columns of a data frame as features, excluding the one chosen as the output. This is done using a single period, as the following code snippets show:
> machine_model1 <- lm(PRP ~ ., data = machine_train) > cars_model1 <- lm(Price ~ ., data = cars_train)
Training a linear regression model may be a one-line affair once we have all our data prepared, but the important work comes straight after, when we study our model in order to determine how well we did. ...