Exercise

Solve a simple problem first

Our goal is to fit a separate linear regression of miles per gallon (mpg) against weight (wt) for each group of cars in our list of data frames, where each data frame in our list represents a different group. How should we get started?

First, let's confirm the structure of this list of data frames. Then, we'll solve a simpler problem first: fit the regression to the first group of cars.

Instructions

100xp

Examine the structure of cyl with str().

Extract the first data frame in cyl and assign it to the variable four_cyls.

Fit a linear regression of miles per gallon on weight using four_cyls as the data argument to lm().