Automobile MPG Predictor App

Kapil Maraj

2026-06-17

The Problem & The Solution

Car buyers often struggle to estimate fuel efficiency when looking at custom or modified vehicle specifications.

Our new Shiny Application solves this by providing:

  • Instant calculations based on core vehicle metrics
  • A simple, no-code graphical user interface
  • Real-time reactive updates as you change parameters

The Underlying Data

The application uses the trusted R mtcars dataset to build its predictive engine. Here is a look at the data structure:

               mpg  hp    wt am
Mazda RX4     21.0 110 2.620  1
Mazda RX4 Wag 21.0 110 2.875  1
Datsun 710    22.8  93 2.320  1

The Predictive Model (Embedded R Code)

We fit a linear regression model (lm) evaluating Miles Per Gallon against Horsepower, Weight, and Transmission type.

fit <- lm(mpg ~ hp + wt + am, data = mtcars)
coef(summary(fit))
               Estimate  Std. Error   t value     Pr(>|t|)
(Intercept) 34.00287512 2.642659337 12.866916 2.824030e-13
hp          -0.03747873 0.009605422 -3.901830 5.464023e-04
wt          -2.87857541 0.904970538 -3.180850 3.574031e-03
am           2.08371013 1.376420152  1.513862 1.412682e-01

Try It Now!

Experience the interactive application live on RStudio’s servers here:
https://shinyapps.io

Source Code

View the complete ui.R and server.R files on GitHub:
https://github.com

Quarto

Quarto enables you to weave together content and executable code into a finished presentation. To learn more about Quarto presentations see https://quarto.org/docs/presentations/.

Bullets

When you click the Render button a document will be generated that includes:

  • Content authored with markdown
  • Output from executable code

Code

When you click the Render button a presentation will be generated that includes both content and the output of embedded code. You can embed code like this:

[1] 2