The idea

Car mileage can be hard to guess.

This app estimates miles per gallon (mpg) from a car’s weight and number of cylinders.

How to use the app

  1. Move the slider to choose the car’s weight.
  2. Select 4, 6, or 8 cylinders.
  3. Read the estimated mpg.

The estimate updates when you change an input.

How the estimate works

The app uses the built-in mtcars dataset and a simple prediction model.

For example, here is the estimate for a car weighing 3,000 pounds with 4 cylinders:

model <- lm(mpg ~ wt + cyl, data = mtcars)
round(predict(model, data.frame(wt = 3, cyl = 4)), 1)
##    1 
## 24.1

Why try it?