Fuel Economy Explorer

Sedat Çapar
September 19, 2026

A simple Shiny application for exploring how vehicle characteristics relate to fuel economy.

Why This App?

Fuel economy depends on several vehicle characteristics.

The app lets a user change:

  • vehicle weight
  • horsepower
  • transmission type

and immediately see a predicted MPG value.

How It Works

The application fits a linear regression model to the built-in mtcars dataset.

data(mtcars)
model <- lm(mpg ~ wt + hp + am, data = mtcars)
round(summary(model)$r.squared, 3)
[1] 0.84

The displayed R expression is evaluated when the presentation is rendered.

Interactive Shiny Workflow

The user selects values with Shiny widgets.

The server then:

  1. reads the selected inputs,
  2. creates a new observation,
  3. predicts MPG with predict(),
  4. displays the result reactively,
  5. places the prediction on a comparison plot.
example_vehicle <- data.frame(wt = 3.0, hp = 150, am = 0)
round(predict(model, newdata = example_vehicle), 1)
   1 
19.7 

Why It Is Useful

  • Simple enough for a novice user.
  • Gives immediate reactive feedback.
  • Demonstrates prediction with a real R dataset.
  • Makes the effect of user-selected inputs easy to explore.
  • Includes on-site documentation in the Shiny interface.

Deploy the app to shinyapps.io and publish this 5-slide presentation to RPubs.