Da Le
2026-09-05
A simple Shiny application for estimating car fuel efficiency from vehicle weight, horsepower, and cylinders.
Fuel efficiency is easy to discuss but harder to estimate intuitively.
This app gives a novice user a simple way to ask:
The app is intentionally small, interactive, and easy to evaluate.
The app uses the built-in mtcars dataset and fits a regression model in server.R.
model <- lm(mpg ~ wt + hp + factor(cyl), data = mtcars)
round(coef(model), 2)
(Intercept) wt hp factor(cyl)6 factor(cyl)8
35.85 -3.18 -0.02 -3.36 -3.19
The user's selections are passed into the model, and the predicted MPG is displayed reactively.
The Shiny interface includes three user inputs:
When the user changes any input, the server recalculates the prediction and updates both the MPG estimate and the comparison chart.
server.R performs a real calculation on user input.