January 02, 2026

What Does It Do?

This interactive Shiny app predicts a car’s Miles Per Gallon (MPG)
based on its horsepower, using a simple linear model.

It allows users to adjust horsepower and get an instant fuel efficiency prediction.

The Dataset & Model

Trained on R’s built-in mtcars dataset
(32 cars with MPG and horsepower measurements)

Linear regression used in the app:

model <- lm(mpg ~ hp, data = mtcars)
coef(model)
## (Intercept)          hp 
## 30.09886054 -0.06822828

How It Works

  • User selects horsepower via a slider
  • The app uses the model to compute MPG
  • The result updates instantly β€” reactive and intuitive
  • Built for ease of use by anyone

Try It Out