An easy way to explore fuel economy in a small car dataset
27 October 2026
How do weight, horsepower, and transmission relate to miles per gallon?
The app lets you change all three and see an estimate straight away.
Choose weight, horsepower, and automatic or manual transmission. A linear model fitted to R's mtcars data calculates the MPG estimate.
This R code is run when the presentation is rendered:
model <- lm(mpg ~ wt + hp + am, data = mtcars)
round(predict(model, newdata = data.frame(wt = 3, hp = 150, am = 0)), 1)
1
19.7
The app places your estimate next to the original 32 cars. Heavier cars generally have lower MPG in this dataset.
The app explains the controls on the page. Its 1973-74 car data make it useful for learning, not for predicting a modern car's official MPG.