2026-07-28

Introduction

This presentation pitches MPG Predictor, a Shiny app that estimates a car’s fuel economy from its weight and horsepower.

  • Built on R’s built-in mtcars dataset
  • Uses a live, reactive linear regression model
  • Try it here: [PASTE YOUR SHINYAPPS.IO URL HERE]

The Problem

Car shoppers often want a quick, intuitive way to estimate fuel economy before comparing specific models.

summary(mtcars$mpg)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   10.40   15.43   19.20   20.09   22.80   33.90

The average MPG in the dataset is about 20.1, ranging from 10.4 to 33.9.

The Model

A simple linear regression predicts MPG from weight and horsepower:

fit <- lm(mpg ~ wt + hp, data = mtcars)
coef(fit)
## (Intercept)          wt          hp 
## 37.22727012 -3.87783074 -0.03177295

Heavier, higher-horsepower cars are predicted to get lower MPG.

The App in Action

predict(fit, data.frame(wt = 3.2, hp = 150))
##        1 
## 20.05227
  • Sliders let the user set weight and horsepower
  • The prediction updates instantly (reactive output)
  • A plot shows the user’s car against the full dataset

Try It Yourself

  • App: [PASTE YOUR SHINYAPPS.IO URL HERE]
  • Code: [PASTE YOUR GITHUB REPO URL HERE]

Thank you!