Sedat Çapar
September 19, 2026
A simple Shiny application for exploring how vehicle characteristics relate to fuel economy.
Fuel economy depends on several vehicle characteristics.
The app lets a user change:
and immediately see a predicted MPG value.
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.
The user selects values with Shiny widgets.
The server then:
predict(),example_vehicle <- data.frame(wt = 3.0, hp = 150, am = 0)
round(predict(model, newdata = example_vehicle), 1)
1
19.7
Deploy the app to shinyapps.io and publish this 5-slide presentation to RPubs.