2026-10-27

Executive Summary

  • Problem: Drivers and car buyers need a quick way to estimate fuel efficiency based on vehicle specifications.
  • Solution: An interactive Shiny Web Application built on the Motor Trend Car Road Tests (mtcars) dataset.
  • Key Features:
    • Reactive prediction based on customizable cylinders, weight, horsepower, and transmission.
    • Built-in user instructions right inside the application UI.
    • Live dataset visualization highlighting the calculated prediction point.

Dataset Overview (mtcars)

The app leverages R’s standard mtcars dataset extracted from the 1974 Motor Trend US magazine (32 automobiles).

head(mtcars[, c("mpg", "cyl", "hp", "wt", "am")], 3)
##                mpg cyl  hp    wt am
## Mazda RX4     21.0   6 110 2.620  1
## Mazda RX4 Wag 21.0   6 110 2.875  1
## Datsun 710    22.8   4  93 2.320  1
fit <- lm(mpg ~ cyl + hp + wt + am, data = mtcars)
summary(fit)$coefficients
##                Estimate Std. Error   t value     Pr(>|t|)
## (Intercept) 36.14653575 3.10478079 11.642218 4.944804e-12
## cyl         -0.74515702 0.58278741 -1.278609 2.119166e-01
## hp          -0.02495106 0.01364614 -1.828433 7.855337e-02
## wt          -2.60648071 0.91983749 -2.833632 8.603218e-03
## am           1.47804771 1.44114927  1.025603 3.141799e-01
# Example User Inputs: 4 Cylinders, 110 HP, 2.5k lbs Weight, Manual Transmission
user_input <- data.frame(cyl = 4, hp = 110, wt = 2.5, am = 1)

# Prediction Output
predicted_val <- predict(fit, newdata = user_input)
paste("Calculated Prediction:", round(predicted_val, 2), "MPG")
## [1] "Calculated Prediction: 25.38 MPG"