FuelLens: Explore the Miles Behind the Machine

Developing Data Products | Course Project
November 3, 2026

An interactive Shiny experiment in fuel economy

Choose a vehicle profile. Compare transmissions. Question the prediction.

Built with the 32 cars in R's mtcars dataset.

FuelLens / MPG Studio

The problem: comparing cars is not comparing like with like

Automatic versus manual looks simple. It isn't.

  • The historical data contain 19 automatic and 13 manual cars.
  • Manual cars show higher raw average MPG, but the two groups differ in weight and horsepower.
  • We need an adjusted, transparent estimate rather than an unqualified claim.

The following R code is evaluated when the presentation is rendered:

with(mtcars, tapply(mpg, factor(am, levels=c(0,1),
                             labels=c("Automatic", "Manual")), mean))
Automatic    Manual 
 17.14737  24.39231 

The product: one dashboard, several ways to learn

From a user's input to a useful comparison

  1. Set the vehicle weight and engine horsepower.
  2. Select automatic or manual transmission.
  3. Get an estimated MPG and 95% prediction interval.
  4. See both transmission model curves and comparable observed cars.
  5. Open How to use FuelLens inside the app for plain-language guidance.

Reactive chain: input sliders -> reactive() vehicle data -> predict() -> renderUI() / renderPlot().

The evidence: model the confounders

Transparent model, explicit assumptions

model <- lm(mpg ~ wt + hp + factor(am), data = mtcars)
round(coef(model), 2)
(Intercept)          wt          hp factor(am)1 
      34.00       -2.88       -0.04        2.08 
                 2.5 %   97.5 %
factor(am)1 -0.7357587 4.903179

The coefficient for factor(am)1 is an adjusted association (manual versus automatic at equal weight and horsepower); it is not causal evidence.

The invitation: explore, don't just accept a score

A small application with honest uncertainty

  • More than a slider demo: predictive comparison, interval estimates, fitted curves and nearest observed cars.
  • Low setup friction: built-in data, one required R package (shiny), no API credentials.
  • Responsible interpretation: 32 historical cars; the user is shown model assumptions and limitations.
round(summary(lm(mpg ~ wt + hp + factor(am), data=mtcars))$r.squared, 3)
[1] 0.84

Visit the live Shiny application via the separate URL submitted in Coursera.

Source: R mtcars (1974 Motor Trend road-test observations).