More shiny









Grayson White

Math 241
Week 6 | Spring 2026

Week 6 Goals

Mon Lecture

  • Introduction to shiny applications
  • Get Project 1 group assignments

Wed Lecture

  • shiny dashboards with Quarto
  • Get all the details about Project 1

Annoucements

  • Updated Instructions for turning in Problem Set 4
    • Turn in the PDF on Gradescope as per usual
      • You may need to set #| eval: false in the chunks that have leaflet maps
    • Also Render your document to HTML (with #| eval: true for the leaflet map chunks)
    • Push the .qmd and .html to GitHub so the graders can grade your leaflet maps and interact with them easily

Recap

  • Inputs: What user manipulates
    • Text
    • Sliders
    • Dropdown menus
    • Action buttons
  • Output: What changes based on user’s selections
    • Graphs
    • Maps
    • Tables
    • Text
  • Use reactive programming
    • Update outputs when inputs change

shiny Recap – Main Components

  • UI: User interface
    • Defines how your app looks
  • Server function
    • Defines how your app works
library(shiny)

# User interface
ui <- fluidPage()

# Server function
server <- function(input, output){}

# Creates app
shinyApp(ui = ui, server = server)

Building Outputs

Server-side:

  • Save the object with output$___.

  • Use a render___({}) function to create the object.

    • Look at cheatsheet for examples.
  • Access inputs with input$___.

UI-side:

  • Place output with ___Output().

Troubleshooting common issues:

  • Must comma separate all the elements in the ui.
  • But don’t add a comma after the last element in the ui.

More Reactivity: observe()

  • Let’s look at another app in the learn-shiny repo.

    • Within the ShinyApps folder, it is in “app_biketown”.
  • Features leaflet functions and observe().

  • Need to use leafletProxy() so that the entire map isn’t redrawn with each update to the inputs.

Adding Source Code to the Dashboard

Create a DESCRIPTION text file with this text:

Title: Math 241 Names

Author: Grayson White

AuthorUrl: https://graysonwhite.shinyapps.io/my_first_app/

DisplayMode: Showcase

Type: Shiny

Uploading to ShinyApps.io

  • Install rsconnect.
install.packages('rsconnect')
library(rsconnect)
  • Configure rsconnect.
setAccountInfo(name="<ACCOUNT>", token="<TOKEN>", secret="<SECRET>")
  • Deploy app. (This will take a couple minutes.)
# Include correct file path
deployApp("ShinyApps/biketown")

Quarto-based shiny dashboards

So Much More…

With that in mind…

Project 1

Big idea:

  • Create an interactive web application/dashboard using shiny or Quarto shiny dashboards.

  • Make sure to satisfy the requirements (given in the handout).

  • But then stretch yourself to add new features and a “non-default” look to your app.

    • Create something you’d want to share in a data science portfolio.
  • Will have opportunities for feedback from your peers and from me as you are iterating toward the final product!

  • Also as part of the project, each group member will write a “data scientist’s statement” and reflect on the goals and design choices of the dashboard.

Practice

Grab appPractice.qmd from the “learn-shiny” Github repo.

Next Week

  • Learn even more about data types in R (strings / dates / factors)
  • Learn to match strings with regular expressions