By default, lm uses the lowest factor as the reference level. To use a different one as reference, we can use the relevel function. Our original model uses 3cyl as the reference level. Perform the following steps to force lm to use 4cyl as the reference:
> auto <- within(auto, cylinders <- relevel(cylinders, ref = "4cyl") ) > mod <- lm(mpg ~., data = auto[t.idx, -c(1, 8, 9)])
The resulting model will not have a coefficient for 4cyl.