2025-05-01

Slide 1: Introduction

Predicting Fuel Efficiency with Shiny

  • Built using shiny, this web application visualises the relationship between a car’s weight and its fuel efficiency (MPG).
  • Users can explore data by selecting number of cylinders from a dropdown menu.
  • The app also displays the average MPG for each selection.

Slide 2: Dataset & Motivation

  • Data source: mtcars dataset from R base.
  • Variables used:
    • wt: Weight (in 1000 lbs)
    • mpg: Miles per gallon
    • cyl: Number of cylinders
  • Motivation: Help users intuitively understand how engine size and car weight affect fuel efficiency.

Slide 3: App Functionality

library(shiny)
shinyUI(fluidPage(
  titlePanel("MPG vs Weight by Cylinder Count"),
  sidebarLayout(
    sidebarPanel(
      selectInput("inputCyl", "Select Number of Cylinders:",
                  choices = sort(unique(mtcars$cyl)))
    ),
    mainPanel(
      plotOutput("mpgPlot"),
      textOutput("avgMPG")
    )
  )
))

Slide 4: Example Output

Application Preview

  • Dropdown updates the plot dynamically
  • Interactive scatterplot displays MPG vs Weight
  • Average MPG recalculated per selection

Slide 5: Deployment & Access